Skip to content

Commit 2bd31c8

Browse files
pettinaripclaude
andcommitted
[recovery] fix: setRequestLocale ordering in resources page (static→dynamic error)
The resources page called getTranslations("page-resources") before ever calling setRequestLocale(locale), and generateMetadata never called it at all. Bot/invalid paths like /api/resources are captured by the [locale] catch-all with "api" as the locale segment. Since that isn't a valid locale in generateStaticParams, the route renders on-demand and next-intl reads the locale from request headers, opting the route into dynamic rendering and throwing: Error: Page changed from static to dynamic at runtime /api/resources, reason: headers Fix: call setRequestLocale(locale) first in both Page and generateMetadata, before any next-intl API. Same fix class as the wallets/videos pages. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 77418ff commit 2bd31c8

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

app/[locale]/resources/page.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { getTranslations } from "next-intl/server"
1+
import { getTranslations, setRequestLocale } from "next-intl/server"
22

33
import type { Lang, PageParams } from "@/lib/types"
44

@@ -35,6 +35,8 @@ const Page = async (props: { params: Promise<PageParams> }) => {
3535
const params = await props.params
3636
const { locale } = params
3737

38+
setRequestLocale(locale)
39+
3840
const t = await getTranslations("page-resources")
3941

4042
// Fetch data using the new data-layer functions (already cached)
@@ -237,6 +239,9 @@ export async function generateMetadata(props: {
237239
const params = await props.params
238240
const { locale } = params
239241

242+
// Set the locale before any next-intl API (getMetadata calls getTranslations)
243+
setRequestLocale(locale)
244+
240245
const t = await getTranslations("page-resources")
241246

242247
return await getMetadata({

0 commit comments

Comments
 (0)