Skip to content

Locale detection isn't working correctly after the update from 15.3 to 15.4/15.5 if a domains array is present in next.config #90131

@EKjs

Description

@EKjs

Link to the code that reproduces this issue

https://codesandbox.io/p/devbox/determined-zhukovsky-vzgqvh?workspaceId=ws_XMt216w8w9LTvcfWfEEkxN

To Reproduce

  1. Open codesandbox url
  2. check that the version of next is 15.5.12
  3. run pnpm install
  4. run pnpm dev
  5. you can also open the dev tools in codesandbox to see more information
  6. click on different links in the demo nextjs app to open different locales
  7. the locales listed in the "domains" array will end up taking the defaultLocale of the "domain" and not the defaultLocale of the main domain. The locales not listed in the "domains" array still work correctly
  8. as you can see, the correct value is still present in the req[Symbol.for("NextInternalRequestMeta")]; but it doesn't affect anything.

Current vs. Expected behavior

v15.5 detects the "defaultLocale" of the "domain" in the "domains" array, although being ran on the defaultDomain.

Also SSR adds the domain to the href of the next/links (and because of this also hydration errors)

Image

in v15.3 no issues were present - both the defaultDomain and the domains from the domains array had always the correct defaultLocale. Also the next/links had the correct links without adding the extra "domain".

For even more information pls see "Additional context"

Provide environment information

This happens on every environment - local, docker, codesandbox.

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 25.3.0: Wed Jan 28 20:48:41 PST 2026; root:xnu-12377.81.4~5/RELEASE_ARM64_T6041
  Available memory (MB): 24576
  Available CPU cores: 14
Binaries:
  Node: 22.22.0
  npm: 10.9.4
  Yarn: 4.12.0
  pnpm: N/A
Relevant Packages:
  next: 15.5.12
  eslint-config-next: N/A
  react: 19.1.0
  react-dom: 19.1.0
  typescript: 5.7.2
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Pages Router, Internationalization (i18n)

Which stage(s) are affected? (Select all that apply)

next dev (local), next build (local), next start (local)

Additional context

Our "default" domain supports all the listed locales.
Our other domains (e.g. "example.fr" has only "fr" and "fr-en", "example.nl" has "nl" and "nl-en"), but the same locales are also supported by the default domain.

in the version 15.3 the locale detection worked perfectly for all these cases.
On the "real" domains, listed in the "domains" array it worked and still works correctly, but the problem is with the "default" domain, that also supports the same locales.

v15.5
open the preview page in codesandbox
default path "/" detects the correct values

locale from GSSP args: de
defaultLocale from GSSP args: de
locale from NextInternalRequestMeta: de
defaultLocale from NextInternalRequestMeta: de
router.locale: de
router.defaultLocale: de

If you click on a NextLink (CSR) to "/fr" - that is listed in the "domains" array - the router still has the correct value for "router.defaultLocale: de", but the defaultLocale from the args is now wrong (should be "de")

locale from GSSP args: fr
defaultLocale from GSSP args: fr
locale from NextInternalRequestMeta: fr
defaultLocale from NextInternalRequestMeta: de
router.locale: fr
router.defaultLocale: de

but if you reload (SSR) the same page "/fr" - router.defaultLocale changes to fr and the defaultLocale from the args is also wrong (both should be "de")

locale from GSSP args: fr
defaultLocale from GSSP args: fr
locale from NextInternalRequestMeta: fr
defaultLocale from NextInternalRequestMeta: de
router.locale: fr
router.defaultLocale: fr

and a hydration error comes up in the console:

Image

so the next/link is adding the domain to the href now.

The locales, that are not listed in the domains, like "/it" - are being detected correctly. Also the "complex" locales for the listed domains - "fr-en" or "nl-en" are working absolute fine.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions