Updated lolisafe.js

Removed file extension check from setHeaders function. It will now apply Cache-Control to all files in /public, and to all files in the uploads folder if they are being served by node.
This commit is contained in:
Bobby Wibowo 2018-04-25 14:30:38 +07:00
parent ebf150938a
commit 498002ee2d
No known key found for this signature in database
GPG Key ID: 51C3A1E1E22D26CF

View File

@ -37,11 +37,10 @@ safe.use('/api/register/', limiter)
safe.use(bodyParser.urlencoded({ extended: true }))
safe.use(bodyParser.json())
const setHeaders = (res, path, stat) => {
if (/\.(3gp|gif|jpg|jpeg|png|ico|wmv|avi|asf|asx|mpg|mpeg|mp4|pls|mp3|mid|wav|swf|flv|exe|zip|tar|rar|gz|tgz|bz2|uha|7z|doc|docx|xls|xlsx|pdf|iso|js|css|eot|svg|ttf|woff|woff2)$/.test(path)) {
res.set('Access-Control-Allow-Origin', '*')
res.set('Cache-Control', 'public, max-age=2592000, must-revalidate, proxy-revalidate, immutable, stale-while-revalidate=86400, stale-if-error=604800') // max-age: 30 days
}
const setHeaders = res => {
// Apply Cache-Control to all static files
res.set('Access-Control-Allow-Origin', '*')
res.set('Cache-Control', 'public, max-age=2592000, must-revalidate, proxy-revalidate, immutable, stale-while-revalidate=86400, stale-if-error=604800') // max-age: 30 days
}
if (config.serveFilesWithNode) {