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];