Skip to content

Commit dc9c0cd

Browse files
pettinaripclaude
andcommitted
[recovery] fix: setRequestLocale ordering in [...slug] generateMetadata
The catch-all [locale]/[...slug] generateMetadata never called setRequestLocale before invoking next-intl APIs. getMdMetadata -> getMetadata calls getTranslations("common"), and the catch block also calls getTranslations("common"). Without setRequestLocale, next-intl reads the locale from request headers for on-demand slugs, opting the route into dynamic rendering and throwing "Page changed from static to dynamic at runtime ... reason: headers". Observed in production via /images/videos/Clw-qf1sUZg.jpg, which maps to the catch-all with locale="images". Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 1473dc4 commit dc9c0cd

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

app/[locale]/[...slug]/page.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,9 @@ export async function generateMetadata(props: {
154154
const params = await props.params
155155
const { locale, slug } = params
156156

157+
// Set locale before next-intl APIs so on-demand renders stay static
158+
setRequestLocale(locale)
159+
157160
try {
158161
return await getMdMetadata({
159162
locale,

0 commit comments

Comments
 (0)