This commit is contained in:
Fasterino
2025-04-12 01:16:54 +03:00
parent fb036c6085
commit 1600435f95
2 changed files with 22 additions and 3 deletions

View File

@@ -52,8 +52,13 @@ export default function getProxy(cfg: Config) {
if (Config.isStatic(proxyData)) { if (Config.isStatic(proxyData)) {
log.PROXY_TYPE = 'STATIC' log.PROXY_TYPE = 'STATIC'
const path = join(volumePath, proxyData.folder, '/' + req.path.substring(proxyData.exclude)) let path = join(volumePath, proxyData.folder, req.path.substring(proxyData.exclude))
log.FILE_PATH = path log.FILE_PATH = path
lstat(path, (err, stat) => {
if (err || !stat.isFile()) {
if (!err && stat.isDirectory()) {
path = join(path, 'index.html')
lstat(path, (err, stat) => { lstat(path, (err, stat) => {
if (err || !stat.isFile()) { if (err || !stat.isFile()) {
log.FILE_FOUND = false log.FILE_FOUND = false
@@ -62,9 +67,23 @@ export default function getProxy(cfg: Config) {
res.status(404).send('<h1>File not exist</h1>') res.status(404).send('<h1>File not exist</h1>')
return return
} }
log.FILE_FOUND = true
prettyLog(log)
res.sendFile(path)
})
return
}
log.FILE_FOUND = false log.FILE_FOUND = false
prettyLog(log) prettyLog(log)
res.status(404).send('<h1>File not exist</h1>')
return
}
log.FILE_FOUND = true
prettyLog(log)
res.sendFile(path) res.sendFile(path)
}) })
return return

View File

@@ -9,6 +9,6 @@
"outDir": "dist" "outDir": "dist"
}, },
"lib": [ "lib": [
"es2015" "es2022"
] ]
} }