From 6f673f806f67c4477b3641d5b0ebcb70a1d84b87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Fri, 21 Oct 2022 10:23:36 -0400 Subject: [PATCH] fix: #10993, apply autoLocale middleware to guests only --- src/middleware/headers.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/middleware/headers.js b/src/middleware/headers.js index dacfb62dec..7f05f11928 100644 --- a/src/middleware/headers.js +++ b/src/middleware/headers.js @@ -86,15 +86,16 @@ module.exports = function (middleware) { } return next(); } - if (parseInt(req.uid, 10) > 0 || !meta.config.autoDetectLang) { - return next(); - } - const langs = await listCodes(); - const lang = req.acceptsLanguages(langs); - if (!lang) { - return next(); + + if (meta.config.autoDetectLang && req.uid === 0) { + const langs = await listCodes(); + const lang = req.acceptsLanguages(langs); + if (!lang) { + return next(); + } + req.query.lang = lang; } - req.query.lang = lang; + next(); });