[recovery] fix: setRequestLocale ordering in video slug page (static→dynamic error)#18785
Draft
pettinarip wants to merge 1 commit into
Draft
[recovery] fix: setRequestLocale ordering in video slug page (static→dynamic error)#18785pettinarip wants to merge 1 commit into
pettinarip wants to merge 1 commit into
Conversation
…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) <noreply@anthropic.com>
✅ Deploy Preview for ethereumorg ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
This was referenced Jul 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Alert
[ERROR] Error: Page changed from static to dynamic at runtime /:locale/videos/.DS_Store, reason: headers___netlify-server-handlerRoot cause
app/[locale]/videos/[slug]/page.tsxcalledgetTranslations("page-videos")beforesetRequestLocale(locale), andgenerateMetadata()never calledsetRequestLocale()at all (it reachesgetTranslationsviagetMetadata).When a next-intl API runs before the request locale is set, next-intl reads the locale from request headers, which opts the route into dynamic rendering. Slugs covered by
generateStaticParamsare prerendered at build (no headers), so they were unaffected. But any slug rendered on-demand — a stale/removed video URL, a typo, or a bot probe like/videos/.DS_Store— hits the header read at request time and Next.js throws "Page changed from static to dynamic at runtime, reason: headers" instead of returning a clean 404.Fix
Call
setRequestLocale(locale)first — before any next-intl API — in both the page component andgenerateMetadata, matching the pattern already used by the sibling videos index page (app/[locale]/videos/page.tsx). Unknown slugs now fall through tonotFound()cleanly.Verification
pnpm type-check✅pnpm exec eslint app/[locale]/videos/[slug]/page.tsx✅🤖 Generated with Claude Code