mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2024-12-14 00:16:21 +00:00
Updated lolisafe.js
If config.cacheControl is enabled, remove Cache-Control header from error pages. Fallbacks to Express' default behavior of using "public, max-age=0".
This commit is contained in:
parent
b75deb268f
commit
4e20f28b78
@ -87,6 +87,7 @@ if (config.cacheControl) {
|
|||||||
next()
|
next()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// For static assets (and uploads if serving with node)
|
||||||
setHeaders = res => {
|
setHeaders = res => {
|
||||||
res.set('Access-Control-Allow-Origin', '*')
|
res.set('Access-Control-Allow-Origin', '*')
|
||||||
res.set('Cache-Control', cacheControls.default)
|
res.set('Cache-Control', cacheControls.default)
|
||||||
@ -139,11 +140,13 @@ safe.use('/api', api)
|
|||||||
|
|
||||||
// Error pages
|
// Error pages
|
||||||
safe.use((req, res, next) => {
|
safe.use((req, res, next) => {
|
||||||
|
if (config.cacheControl) res.removeHeader('Cache-Control')
|
||||||
res.status(404).sendFile(path.join(paths.errorRoot, config.errorPages[404]))
|
res.status(404).sendFile(path.join(paths.errorRoot, config.errorPages[404]))
|
||||||
})
|
})
|
||||||
|
|
||||||
safe.use((error, req, res, next) => {
|
safe.use((error, req, res, next) => {
|
||||||
logger.error(error)
|
logger.error(error)
|
||||||
|
if (config.cacheControl) res.removeHeader('Cache-Control')
|
||||||
res.status(500).sendFile(path.join(paths.errorRoot, config.errorPages[500]))
|
res.status(500).sendFile(path.join(paths.errorRoot, config.errorPages[500]))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user