Domain routing i18n adds default locale to link href's

Link to the code that reproduces this issue

https://codesandbox.io/p/devbox/nice-bose-p9y9lt?workspaceId=8c42ce9b-a788-4790-894d-50229e1eadea

To Reproduce

The codesandbox is a simplified setup of our site and config. This should be run with domain routing.

Current vs. Expected behavior

In the example code, the link components that are resolved on the server, get the default locale as an infix. An example of where this happens is on diamondsbyme.com/rings/. The menu and product links are structured as a relative link with the locale, even if it is the default locale (en) for that domain, resulting in the link being https://www.diamondsbyme.com/en/rings/.

This should just resolve to https://www.diamondsbyme.com/rings/ on the server, as it did previously. On previous deployments this behavior wasn’t present. When the link is resolved via client side routing, the default locale is not present in the href. This can be tested on the example link by navigating via the menu to, for example, “Men’s rings”. The products will change and not have the default locale infix in the href, it even is the complete URL.

Refreshing the page will include the default locale again as a relative link.

I’ve downgraded to 14.2.10 and even to 14.2.3 but the issue still persists.

Provide environment information

Operating System:
  Platform: darwin
  Arch: x64
  Version: Darwin Kernel Version 23.6.0: Mon Jul 29 21:13:00 PDT 2024; root:xnu-10063.141.2~1/RELEASE_X86_64
  Available memory (MB): 40960
  Available CPU cores: 16
Binaries:
  Node: 21.6.2
  npm: 10.2.4
  Yarn: 1.22.22
  pnpm: 9.12.2
Relevant Packages:
  next: 14.2.10 // An outdated version detected (latest is 15.0.1), upgrade is highly recommended!
  eslint-config-next: 14.2.3
  react: 18.2.0
  react-dom: 18.2.0
  typescript: N/A
Next.js Config:
  output: N/A

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

Internationalization (i18n), Navigation, Pages Router

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

Vercel (Deployed)

Additional context

The build output uses the full URL in the outputted HTML files. It’s only for a revalidated page

Deployment URL or Custom Domain: https://dbm-knx7h4q0s-dbm-com.vercel.app/ and https://www.diamondsbyme.com/
Environment (local, preview, production): production
Project Framework: Next.js
Build Settings:
  Framework Preset:
  Build Command (if not default):
  Output Directory (if not default):
  Install Command (if not default):
Node/Runtime Version:
Package Manager:
Relevant Packages:

Hey @gijsbotje. Thanks for sharing the domain. It appears to work as expected when I visit the site. The /en/[page]/ links go to /[page]. It also goes to the appropriate /[page] address if I visit /en/[page] directory in the address bar. Do you see something different happen when you navigate the site?

Hi @amyegan,

The problem is the HTML response of the server. Client side everything woks as expected, but the response from the server is the issue. That’s what Google indexes and scrapers find.
You can even see it in your screenshot.

The build output in Vercel is different from the response you get, how is that?

2 weeks ago this didn’t happen for these sites:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.