TRAC-1298: Update locale paths to runtime resolution - #3173
Open
jordanarldt wants to merge 1 commit into
Open
Conversation
🦋 Changeset detectedLatest commit: c4976fa The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
Bundle Size ReportComparing against baseline from
Per-Route First Load JS
|
Contributor
Unlighthouse Performance Comparison — VercelComparing PR preview deployment Unlighthouse scores vs production Unlighthouse scores. Summary ScoreAggregate score across all categories as reported by Unlighthouse.
Category Scores
Core Web Vitals
|
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.
What/Why?
Custom locale subfolders (
/fr-fr,/es-es) didn't resolve consistently. The table was snapshotted intobuild-config.jsonat build time, so incomplete data duringnext build404'd every localized URL until the next deploy — and next-intl treats a custom subfolder as a replacement for the bare locale code, not an alias, so there was no fallback.Locale config is now fetched at runtime and is the only source.
withIntlresolves it once per request (KV-cached, SWR, 5 min) and forwards it to the render viax-bc-locale-routing, so outbound URLs match what resolved the inbound one. No build-time fallback was kept — it would silently serve the stale URL space this fixes. A warm cache rides out an outage; only a cold cache plus an unreachable API fails, returning503rather than a 404.Worth a look:
redirect/permanentRedirectmoved to~/i18n/navigation-serverand are nowasync— they can't stay in~/i18n/routing, which is in the client graph wherenext/headersfails the build.~/i18n/localesis removed.i18n/request.tsreads the forwarded header only; fetching there would recurse viaclient.fetch→getLocale().generateStaticParamsremoved fromapp/[locale]/layout.tsx. Route modes in the build are unchanged./xmlsitemap.php, which resolved to/<locale>/sitemap.xml— a 404, since/sitemap.xmlis excluded from the proxy.Locale detection is unchanged.
Testing
pnpm build && pnpm start, then:/xmlsitemap.phplands on/sitemap.xml.Accept-Language: deon/redirects to German; switching locale in the header sticks on reload.Plus
tests/ui/e2e/locale-switcher.spec.ts.Migration
redirect/permanentRedirectmove, and must be awaited:~/i18n/localesis gone — usegetLocaleRouting()from~/i18n/locale-config.Link,useRouterandusePathnamekeep their~/i18n/routingimport.If you map locales to channels in
channels.config.ts: sitemap, robots and favicon now resolve the default channel directly, as they run outside the proxy.