diff --git a/src/app.js b/src/app.js index 99ee2fa..7a06b51 100644 --- a/src/app.js +++ b/src/app.js @@ -17,7 +17,7 @@ app.use(helmet({ contentSecurityPolicy: false })); morgan.token('user-ip', function(req) { - return execMode == "pro" ? req.headers['X-Real-IP'] : req.ip; + return execMode == "pro" ? req.headers['x-real-ip'] : req.ip; }); morgan.token('accepted-cookies', function(req) { return Boolean(req.cookies['cookie-accepted']); diff --git a/src/middlewares/morgan.js b/src/middlewares/morgan.js index 578ff4b..6a196fb 100644 --- a/src/middlewares/morgan.js +++ b/src/middlewares/morgan.js @@ -8,7 +8,12 @@ function assignId(req, res, next) { function skipStatics(req, res) { const staticFilesPrefixes = ['/css', '/js', '/images', '/img', '/fonts']; - return staticFilesPrefixes.some(prefix => req.originalUrl.startsWith(prefix)); + const fileExtensionsToSkip = ['.js', '.css', '.png', '.jpg', '.jpeg']; + + const shouldSkipFileExtension = fileExtensionsToSkip.some(extension => req.originalUrl.endsWith(extension)); + const shouldSkipStaticFile = staticFilesPrefixes.some(prefix => req.originalUrl.startsWith(prefix)); + + return shouldSkipFileExtension || shouldSkipStaticFile; } function skipStatusServer(req, res) {