mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-07 18:32:40 +00:00
Merge branch 'Issue_1958' of github.com:dbolacksn/homebrewery-broken into Issue_1958
Only except /staticImages with a `local` NODE_ENV
This commit is contained in:
@@ -3,15 +3,16 @@ const nodeEnv = config.get('node_env');
|
|||||||
const isLocalEnvironment = config.get('local_environments').includes(nodeEnv);
|
const isLocalEnvironment = config.get('local_environments').includes(nodeEnv);
|
||||||
|
|
||||||
module.exports = (req, res, next)=>{
|
module.exports = (req, res, next)=>{
|
||||||
if((!isLocalEnvironment) && (!req.url?.startsWith('/staticImages') && !req.url?.startsWith('/staticFonts'))) {
|
const isImageRequest = req.get('Accept')?.split(',')
|
||||||
const isImageRequest = req.get('Accept')?.split(',')
|
?.filter((h)=>!h.includes('q='))
|
||||||
?.filter((h)=>!h.includes('q='))
|
?.every((h)=>/image\/.*/.test(h));
|
||||||
?.every((h)=>/image\/.*/.test(h));
|
if(isImageRequest &&
|
||||||
if(isImageRequest) {
|
(!isLocalEnvironment && !req.url?.startsWith('/staticImages'))
|
||||||
return res.status(406).send({
|
) {
|
||||||
message : 'Request for image at this URL is not supported'
|
return res.status(406).send({
|
||||||
});
|
message : 'Request for image at this URL is not supported'
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
next();
|
next();
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user