From 2c3cb593157ce4a03b152a36ea28a24cd17bfee4 Mon Sep 17 00:00:00 2001 From: Khodor Ammar Date: Sun, 16 Dec 2018 09:45:13 +0400 Subject: [PATCH] preserve original querystring parameters by appending them with lng --- src/middlewares/next-i18next-middleware.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/middlewares/next-i18next-middleware.js b/src/middlewares/next-i18next-middleware.js index ab97c58f..d00f41c3 100644 --- a/src/middlewares/next-i18next-middleware.js +++ b/src/middlewares/next-i18next-middleware.js @@ -14,8 +14,9 @@ export default function (nexti18next, app, server) { server.get(/^\/(?!_next|static).*$/, lngPathDetector) server.get(`/:lng(${allLanguages.join('|')})/*`, (req, res) => { const { lng } = req.params + const { query } = req const url = parse(req.url).pathname - app.render(req, res, url.replace(`/${lng}`, ''), { lng }) + app.render(req, res, url.replace(`/${lng}`, ''), { lng, ...query }) }) } }