fix(i18n): use correct defaultLocale when domains array is present on default host#93151
Open
hammadxcm wants to merge 1 commit intovercel:canaryfrom
Open
fix(i18n): use correct defaultLocale when domains array is present on default host#93151hammadxcm wants to merge 1 commit intovercel:canaryfrom
hammadxcm wants to merge 1 commit intovercel:canaryfrom
Conversation
… default host When a `domains` array is configured in i18n and the request is served from the default domain (e.g., localhost), `defaultLocale` was incorrectly set to a configured domain's value because `detectDomainLocale` matched on the detected locale rather than hostname. Remove `domainLocale?.defaultLocale` from the fallback chain in `RouteModule.prepare()` since `base-server.ts` already sets the correct value in request metadata via hostname-only matching. Fixes vercel#90131
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?
Fixes the
defaultLocaleresolution inRouteModule.prepare()when adomainsarray is configured in the i18n config and the request is served from the default domain (not a configured domain hostname).Why?
When visiting a locale path like
/fron the default domain (e.g.,localhost),detectDomainLocale()matches a configured domain entry (e.g.,example.fr) based on the detected locale — not hostname. The matched domain'sdefaultLocalewas then incorrectly used as the request'sdefaultLocale, causing:defaultLocaleingetServerSideProps/getStaticPropsargsrouter.defaultLocaleon SSR (sent via__NEXT_DATA__)<Link>components rendering domain-prefixed hrefsThis is a regression introduced between v15.3 and v15.4 when the Pages Router handler was refactored to use
RouteModule.prepare().How?
Removed
domainLocale?.defaultLocalefrom thedefaultLocalefallback chain inRouteModule.prepare(). The correctdefaultLocaleis already set in request metadata bybase-server.tsusing hostname-only domain matching, so the locale-matcheddomainLocalevalue is not needed here.The
domainLocalevariable (with locale-based matching) is still used forisLocaleDomain— which is needed for domain-prefixed link generation.Before:
After:
Test plan
/go/anotherand/do/anotheron localhost (nohostheader) and verifiesdefaultLocaleisen-US(main config) in both GSSP props androuter.defaultLocaleFixes #90131