From 975345f8b1aeec5d8fc1a09b575d74c7ed8fb32c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=BChn?= Date: Thu, 8 Oct 2026 15:22:47 +0200 Subject: [PATCH] Fix MPM root route redirect loop --- module-runtime.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/module-runtime.js b/module-runtime.js index dabe0cd..0872172 100644 --- a/module-runtime.js +++ b/module-runtime.js @@ -28,7 +28,11 @@ const server = createModuleServer({ logger, identityRequired: true, routes(request, response, context) { - const targetPath = `${basePath}${context.url.pathname}${context.url.search}`; + // Next.js treats the configured base path itself as the canonical root + // (without a trailing slash). Keep `/kalendartool` stable when MPM routes + // an incoming `/kalendartool` request as the module path `/`. + const modulePath = context.url.pathname === '/' ? '' : context.url.pathname; + const targetPath = `${basePath}${modulePath}${context.url.search}`; const headers = { ...request.headers, host: `127.0.0.1:${nextPort}` }; for (const name of Object.keys(headers)) { if (name.startsWith('x-kalendartool-mpm-')) delete headers[name];