Skip to content

[recovery] fix: setRequestLocale ordering in video slug page (static→dynamic error)#18785

Draft
pettinarip wants to merge 1 commit into
devfrom
recovery/fix/videos-slug-setrequestlocale-order
Draft

[recovery] fix: setRequestLocale ordering in video slug page (static→dynamic error)#18785
pettinarip wants to merge 1 commit into
devfrom
recovery/fix/videos-slug-setrequestlocale-order

Conversation

@pettinarip

Copy link
Copy Markdown
Member

Alert

Root cause

app/[locale]/videos/[slug]/page.tsx called getTranslations("page-videos") before setRequestLocale(locale), and generateMetadata() never called setRequestLocale() at all (it reaches getTranslations via getMetadata).

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 generateStaticParams are 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 and generateMetadata, matching the pattern already used by the sibling videos index page (app/[locale]/videos/page.tsx). Unknown slugs now fall through to notFound() cleanly.

Verification

  • pnpm type-check
  • pnpm exec eslint app/[locale]/videos/[slug]/page.tsx

🤖 Generated with Claude Code

…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>
@pettinarip pettinarip added the recovery-agent Created by the Recovery Agent label Jul 13, 2026
@netlify

netlify Bot commented Jul 13, 2026

Copy link
Copy Markdown

Deploy Preview for ethereumorg ready!

Name Link
🔨 Latest commit e52f5c9
🔍 Latest deploy log https://app.netlify.com/projects/ethereumorg/deploys/6a5575da121b750009fe6b85
😎 Deploy Preview https://deploy-preview-18785.ethereum.it
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
7 paths audited
Performance: 59 (🟢 up 3 from production)
Accessibility: 95 (no change from production)
Best Practices: 100 (no change from production)
SEO: 98 (no change from production)
PWA: 59 (🔴 down 1 from production)
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

recovery-agent Created by the Recovery Agent

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant