mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2025-02-07 13:59:01 +00:00
fix: cache-control broken with cloudflare setting
This commit is contained in:
parent
0f6409132a
commit
e82cf714dd
10
lolisafe.js
10
lolisafe.js
@ -155,11 +155,15 @@ if (config.cacheControl) {
|
|||||||
case true:
|
case true:
|
||||||
// If using CDN, cache public pages in CDN
|
// If using CDN, cache public pages in CDN
|
||||||
cdnPages.push('api/check')
|
cdnPages.push('api/check')
|
||||||
for (const page of cdnPages) {
|
safe.use((req, res, next) => {
|
||||||
safe.get(`/${page === 'home' ? '' : page}`, async (req, res) => {
|
if (req.method === 'GET' || req.method === 'HEAD') {
|
||||||
|
const page = req.path === '/' ? 'home' : req.path.substring(1)
|
||||||
|
if (cdnPages.includes(page)) {
|
||||||
res.set('Cache-Control', cacheControls.cdn)
|
res.set('Cache-Control', cacheControls.cdn)
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
return next()
|
||||||
|
})
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user