diff --git a/packages/next/server/base-server.ts b/packages/next/server/base-server.ts index b2b07f66ca006..9182931e180ef 100644 --- a/packages/next/server/base-server.ts +++ b/packages/next/server/base-server.ts @@ -526,6 +526,15 @@ export default abstract class Server { typeof req.headers['x-matched-path'] === 'string' ) { try { + if (this.hasAppDir) { + // ensure /index path is normalized for prerender + // in minimal mode + if (req.url.match(/^\/index($|\?)/)) { + req.url = req.url.replace(/^\/index/, '/') + } + parsedUrl.pathname = + parsedUrl.pathname === '/index' ? '/' : parsedUrl.pathname + } // x-matched-path is the source of truth, it tells what page // should be rendered because we don't process rewrites in minimalMode let matchedPath = normalizeRscPath(