Skip to content

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

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

[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

@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 3be76cb
🔍 Latest deploy log https://app.netlify.com/projects/ethereumorg/deploys/6a57b6a764f7f900088068f9
😎 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: 58 (🟢 up 2 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.

…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 force-pushed the recovery/fix/videos-slug-setrequestlocale-order branch from e52f5c9 to 3be76cb Compare July 15, 2026 16:34
pettinarip added a commit that referenced this pull request Jul 15, 2026
…amic error)

The /wallets page (app/[locale]/wallets/page.tsx) called
getTranslations("page-wallets") before setRequestLocale(locale), and
generateMetadata never called setRequestLocale at all. For locales rendered
on-demand — e.g. a bot probe like /api/wallets where "api" is captured as the
[locale] param and is not covered by generateStaticParams — next-intl falls
back to reading the locale from request headers. That opts the route into
dynamic rendering and Next.js throws "Page changed from static to dynamic at
runtime /api/wallets, reason: headers" (stack shows get requestLocale) instead
of rendering statically.

Call setRequestLocale(locale) first in both the page and generateMetadata,
mirroring the fix in PR #18785 for the videos [slug] page.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@pettinarip pettinarip marked this pull request as ready for review July 15, 2026 16:39
@pettinarip pettinarip requested a review from wackerow as a code owner July 15, 2026 16:39
@github-actions

Copy link
Copy Markdown
Contributor

🔎 First-pass review — ✅ Looks mergeable

Minimal, correct fix for the static→dynamic (reason: headers) error on on-demand video slugs. setRequestLocale(locale) now runs before any next-intl API in both the page component and generateMetadata, so on-demand renders (typos, stale URLs, bot probes like /videos/.DS_Store) fall through to notFound() cleanly instead of triggering a header read that forces dynamic rendering.

Analysis
  • Lane: code (app/[locale]/videos/[slug]/page.tsx, +6/-1). Base branch dev — correct.
  • Verified: page component sets locale before getTranslations("page-videos"); generateMetadata sets it before getVideoData / getMetadata / getTranslations("common") — the ordering fix is complete on both entry points.
  • Convention check: no unused vars, no raw Intl.*, no ChainName surface, no new component variants. Nothing for review here.
  • Nit (non-blocking): the PR body says it matches the sibling index page pattern — accurate for the page body, but the sibling generateMetadata in app/[locale]/videos/page.tsx does not call setRequestLocale. This PR is the more correct version; the sibling could get the same treatment in a follow-up.
  • CI: let checks finish before merge.

Generated by PR Reviewer (team) for #18785 · 67.7 AIC · ⌖ 10.2 AIC · ⊞ 5.2K ·

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