0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-24 14:12:40 +00:00

Except staticImages and staticFonts paths from middleware evaluation if in a local ENV.

This commit is contained in:
David Bolack
2024-09-06 11:50:46 -05:00
parent 4dc5746c71
commit d19aaf6c78
2 changed files with 15 additions and 10 deletions

View File

@@ -7,4 +7,4 @@
"enable_themes" : true,
"local_environments" : ["docker", "local"],
"publicUrl" : "https://homebrewery.naturalcrit.com"
}
}

View File

@@ -1,12 +1,17 @@
module.exports = (req, res, next)=>{
const isImageRequest = req.get('Accept')?.split(',')
?.filter((h)=>!h.includes('q='))
?.every((h)=>/image\/.*/.test(h));
if(isImageRequest) {
return res.status(406).send({
message : 'Request for image at this URL is not supported'
});
}
const config = require('../config.js');
const nodeEnv = config.get('node_env');
const isLocalEnvironment = config.get('local_environments').includes(nodeEnv);
module.exports = (req, res, next)=>{
if((!isLocalEnvironment) && (!req.url?.startsWith('/staticImages') && !req.url?.startsWith('/staticFonts'))) {
const isImageRequest = req.get('Accept')?.split(',')
?.filter((h)=>!h.includes('q='))
?.every((h)=>/image\/.*/.test(h));
if(isImageRequest) {
return res.status(406).send({
message : 'Request for image at this URL is not supported'
});
}
}
next();
};