diff --git a/config/default.json b/config/default.json index 12b35e6cf..7d36368f6 100644 --- a/config/default.json +++ b/config/default.json @@ -7,4 +7,4 @@ "enable_themes" : true, "local_environments" : ["docker", "local"], "publicUrl" : "https://homebrewery.naturalcrit.com" -} + } diff --git a/server/middleware/content-negotiation.js b/server/middleware/content-negotiation.js index 201e64a25..4eb9137ba 100644 --- a/server/middleware/content-negotiation.js +++ b/server/middleware/content-negotiation.js @@ -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(); }; \ No newline at end of file