diff --git a/packages/next/build/utils.ts b/packages/next/build/utils.ts index b0332a1f5a8981..61691ce6d9e338 100644 --- a/packages/next/build/utils.ts +++ b/packages/next/build/utils.ts @@ -1207,7 +1207,7 @@ export async function copyTracedFiles( for (const page of pageKeys) { if (MIDDLEWARE_ROUTE.test(page)) { const { files } = - middlewareManifest.middleware[page.replace(/\/_middleware$/, '')] + middlewareManifest.middleware[page.replace(/\/_middleware$/, '') || '/'] for (const file of files) { const originalPath = path.join(distDir, file)