Unverified Commit 8f4e4b64 authored by Jiwon Choi's avatar Jiwon Choi Committed by GitHub

Restore static metadata prerendering for dynamic routes (#99463)

Static metadata files nested under dynamic routes use placeholder paths
with empty params. The build treats those routes as missing
`generateStaticParams()`, which breaks adapter deployments.

This is a temporary hotfix, will follow up with better refactor of the
handling
parent 7297fe2a
......@@ -2680,9 +2680,12 @@ export default async function build(
workerResult.prerenderedRoutes.length > 0 &&
// in PPR, we create fallback routes with empty params.
// If at least one non-empty param exists, it must've been
// generated by `generateStaticParams`.
// generated by `generateStaticParams`. Static metadata files
// use a placeholder path with empty params instead.
workerResult.prerenderedRoutes.some(
(route) => !isEmptyParams(route.params)
(route) =>
isStaticMetadataFile(route.pathname) ||
!isEmptyParams(route.params)
)
if (isDynamic && !hasGenerateStaticParams) {
if (config.output === 'export') {
......
......@@ -11,5 +11,9 @@ describe('metadata-static-file-gsp', () => {
it('should build and serve a static metadata file colocated with generateStaticParams', async () => {
await next.render('/results/two')
const response = await next.fetch('/results/-/opengraph-image.png')
expect(response.status).toBe(200)
expect(response.headers.get('content-type')).toBe('image/png')
})
})
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment