Fix MPM root route redirect loop
This commit is contained in:
@@ -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];
|
||||
|
||||
Reference in New Issue
Block a user