mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-08 20:23:39 +00:00
Except staticImages and staticFonts paths from middleware evaluation if in a local ENV.
This commit is contained in:
@@ -1,4 +1,9 @@
|
|||||||
|
const config = require('../config.js');
|
||||||
|
const nodeEnv = config.get('node_env');
|
||||||
|
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));
|
||||||
@@ -7,6 +12,6 @@ module.exports = (req, res, next)=>{
|
|||||||
message : 'Request for image at this URL is not supported'
|
message : 'Request for image at this URL is not supported'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
next();
|
next();
|
||||||
};
|
};
|
||||||
Reference in New Issue
Block a user