Unverified Commit 63090e20 authored by Zack Tanner's avatar Zack Tanner Committed by GitHub

fix: pages router metadata bugs with React 19 (#81733)

When we updated `experimental.strictNextHead` to be true in #65418, we
did not update all spots that would default to true in the case where
the value was omitted entirely.

This led to the default value not being correctly applied in pages
router, which resulted in duplicate metadata w/ React 19.

Since we made the flag the default, we can also probably clean up this
flag all together, but that can be done separately.

Fixes #81655
Fixes #81689
parent 2eac9dcc
...@@ -289,9 +289,8 @@ export async function handler( ...@@ -289,9 +289,8 @@ export async function handler(
reactLoadableManifest, reactLoadableManifest,
assetPrefix: nextConfig.assetPrefix, assetPrefix: nextConfig.assetPrefix,
strictNextHead: Boolean( strictNextHead:
nextConfig.experimental.strictNextHead nextConfig.experimental.strictNextHead ?? true,
),
previewProps: prerenderManifest.preview, previewProps: prerenderManifest.preview,
images: nextConfig.images as any, images: nextConfig.images as any,
nextConfigOutput: nextConfig.output, nextConfigOutput: nextConfig.output,
......
...@@ -1466,6 +1466,7 @@ export const defaultConfig = Object.freeze({ ...@@ -1466,6 +1466,7 @@ export const defaultConfig = Object.freeze({
devtoolSegmentExplorer: false, devtoolSegmentExplorer: false,
browserDebugInfoInTerminal: false, browserDebugInfoInTerminal: false,
optimizeRouterScrolling: false, optimizeRouterScrolling: false,
strictNextHead: true,
}, },
htmlLimitedBots: undefined, htmlLimitedBots: undefined,
bundlePagesRouterDependencies: false, bundlePagesRouterDependencies: false,
......
...@@ -4,9 +4,12 @@ module.exports = { ...@@ -4,9 +4,12 @@ module.exports = {
// Make sure entries are not getting disposed. // Make sure entries are not getting disposed.
maxInactiveAge: 1000 * 60 * 60, maxInactiveAge: 1000 * 60 * 60,
}, },
experimental: { experimental:
strictNextHead: process.env.TEST_STRICT_NEXT_HEAD !== 'false', process.env.TEST_STRICT_NEXT_HEAD !== undefined
}, ? {
strictNextHead: process.env.TEST_STRICT_NEXT_HEAD === 'true',
}
: {},
// scroll position can be finicky with the // scroll position can be finicky with the
// indicators showing so hide by default // indicators showing so hide by default
devIndicators: false, devIndicators: false,
......
import Head from 'next/head'
export default function Page() {
return (
<div>
<Head>
<title>Title Page</title>
<meta property="og:title" content="Title Content" />
<meta name="description" content="Description Content" />
</Head>
<p>This is a page!</p>
</div>
)
}
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