mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-02 15:02:38 +00:00
Except staticImages and staticFonts paths from middleware evaluation if in a local ENV.
This commit is contained in:
@@ -7,4 +7,4 @@
|
|||||||
"enable_themes" : true,
|
"enable_themes" : true,
|
||||||
"local_environments" : ["docker", "local"],
|
"local_environments" : ["docker", "local"],
|
||||||
"publicUrl" : "https://homebrewery.naturalcrit.com"
|
"publicUrl" : "https://homebrewery.naturalcrit.com"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,17 @@
|
|||||||
module.exports = (req, res, next)=>{
|
const config = require('../config.js');
|
||||||
const isImageRequest = req.get('Accept')?.split(',')
|
const nodeEnv = config.get('node_env');
|
||||||
?.filter((h)=>!h.includes('q='))
|
const isLocalEnvironment = config.get('local_environments').includes(nodeEnv);
|
||||||
?.every((h)=>/image\/.*/.test(h));
|
|
||||||
if(isImageRequest) {
|
|
||||||
return res.status(406).send({
|
|
||||||
message : 'Request for image at this URL is not supported'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
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();
|
next();
|
||||||
};
|
};
|
||||||
Reference in New Issue
Block a user