From 3be76cbf1f0e2bbf9d95148c81f31f3307b5dab9 Mon Sep 17 00:00:00 2001 From: Pablo Pettinari Date: Mon, 13 Jul 2026 23:33:17 +0000 Subject: [PATCH] [recovery] fix: call setRequestLocale before next-intl APIs in video slug page The video [slug] page called getTranslations() before setRequestLocale(), and generateMetadata() never called setRequestLocale() at all. When next-intl runs before the locale is set for the request, it reads the locale from request headers, which opts the route into dynamic rendering. For slugs not covered by generateStaticParams (e.g. stale/removed video URLs, or bot probes like /videos/.DS_Store), the page renders on-demand, hits the header read, and Next.js throws: Error: Page changed from static to dynamic at runtime /:locale/videos/.DS_Store, reason: headers Reorder so setRequestLocale(locale) runs first in both the page component and generateMetadata (which reaches getTranslations via getMetadata), matching the pattern used by the sibling videos index page. Unknown slugs now 404 cleanly via notFound() instead of throwing a runtime error. Co-Authored-By: Claude Opus 4.8 (1M context) --- app/[locale]/videos/[slug]/page.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/[locale]/videos/[slug]/page.tsx b/app/[locale]/videos/[slug]/page.tsx index 56702c2a75b..2215087fd05 100644 --- a/app/[locale]/videos/[slug]/page.tsx +++ b/app/[locale]/videos/[slug]/page.tsx @@ -29,9 +29,11 @@ const VideoLandingPage = async (props: { }) => { const { locale, slug } = await props.params - const t = await getTranslations("page-videos") + // Set locale before next-intl APIs so on-demand renders stay static setRequestLocale(locale) + const t = await getTranslations("page-videos") + let data: VideoData | undefined try { data = await getVideoData(slug, locale) @@ -110,6 +112,9 @@ export async function generateMetadata(props: { }): Promise { const { locale, slug } = await props.params + // Set locale before next-intl APIs so on-demand renders stay static + setRequestLocale(locale) + let data try { data = await getVideoData(slug, locale)