update
This commit is contained in:
21
src/proxy.ts
21
src/proxy.ts
@@ -52,8 +52,13 @@ export default function getProxy(cfg: Config) {
|
||||
|
||||
if (Config.isStatic(proxyData)) {
|
||||
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
|
||||
lstat(path, (err, stat) => {
|
||||
if (err || !stat.isFile()) {
|
||||
if (!err && stat.isDirectory()) {
|
||||
path = join(path, 'index.html')
|
||||
|
||||
lstat(path, (err, stat) => {
|
||||
if (err || !stat.isFile()) {
|
||||
log.FILE_FOUND = false
|
||||
@@ -62,9 +67,23 @@ export default function getProxy(cfg: Config) {
|
||||
res.status(404).send('<h1>File not exist</h1>')
|
||||
return
|
||||
}
|
||||
|
||||
log.FILE_FOUND = true
|
||||
prettyLog(log)
|
||||
|
||||
res.sendFile(path)
|
||||
})
|
||||
return
|
||||
}
|
||||
log.FILE_FOUND = false
|
||||
prettyLog(log)
|
||||
|
||||
res.status(404).send('<h1>File not exist</h1>')
|
||||
return
|
||||
}
|
||||
log.FILE_FOUND = true
|
||||
prettyLog(log)
|
||||
|
||||
res.sendFile(path)
|
||||
})
|
||||
return
|
||||
|
||||
@@ -9,6 +9,6 @@
|
||||
"outDir": "dist"
|
||||
},
|
||||
"lib": [
|
||||
"es2015"
|
||||
"es2022"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user