Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: fix pages in Route Groups returning 500 with output: "standalone" #43746

Merged
merged 13 commits into from Dec 13, 2022
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions packages/next/build/index.ts
Expand Up @@ -536,6 +536,7 @@ export default async function build(
)

let mappedAppPages: { [page: string]: string } | undefined
let mapAppPagesToNormalized: Record<string, string> | undefined

if (appPaths && appDir) {
mappedAppPages = nextBuildSpan
Expand Down Expand Up @@ -586,6 +587,7 @@ export default async function build(
const conflictingAppPagePaths: [pagePath: string, appPath: string][] = []
const appPageKeys: string[] = []
if (mappedAppPages) {
mapAppPagesToNormalized = {}
for (const appKey in mappedAppPages) {
const normalizedAppPageKey = normalizeAppPath(appKey) || '/'
const pagePath = mappedPages[normalizedAppPageKey]
Expand All @@ -596,7 +598,7 @@ export default async function build(
appPath.replace(/^private-next-app-dir/, 'app'),
])
}

mapAppPagesToNormalized[appKey] = normalizedAppPageKey
appPageKeys.push(normalizedAppPageKey)
}
}
Expand Down Expand Up @@ -2068,7 +2070,7 @@ export default async function build(
dir,
distDir,
pageKeys.pages,
pageKeys.app,
mapAppPagesToNormalized,
outputFileTracingRoot,
requiredServerFiles.config,
middlewareManifest
Expand Down
8 changes: 4 additions & 4 deletions packages/next/build/utils.ts
Expand Up @@ -1598,7 +1598,7 @@ export async function copyTracedFiles(
dir: string,
distDir: string,
pageKeys: ReadonlyArray<string>,
appPageKeys: readonly string[] | undefined,
appPageKeys: Record<string, string> | undefined,
tracingRoot: string,
serverConfig: { [key: string]: any },
middlewareManifest: MiddlewareManifest
Expand Down Expand Up @@ -1708,11 +1708,11 @@ export async function copyTracedFiles(
})
}
if (appPageKeys) {
for (const page of appPageKeys) {
if (middlewareManifest.functions.hasOwnProperty(page)) {
for (const page in appPageKeys) {
if (middlewareManifest.functions.hasOwnProperty(appPageKeys[page])) {
continue
}
const pageFile = path.join(distDir, 'server', 'app', `${page}`, 'page.js')
const pageFile = path.join(distDir, 'server', 'app', `${page}.js`)
const pageTraceFile = `${pageFile}.nft.json`
await handleTraceFiles(pageTraceFile).catch((err) => {
Log.warn(`Failed to copy traced files for ${pageFile}`, err)
Expand Down