Skip to main content
GoodFirstPicks
DashboardIssuesReposLeaderboard

GoodFirstPicks by Leaveitblank © 2026

CreatorRequest a RepoPrivacy PolicyTerms of Service
Incorrect Location header URL with domain routing i18n | GoodFirstPicks

Incorrect Location header URL with domain routing i18n

vercel/next.js 2 comments 1mo ago
View on GitHub
mediumopenScope: somewhat clearSkill match: maybeNext.jsTypeScriptReact

Why this is a good first issue

Domain routing and i18n configuration cause incorrect URL redirection.

AI Summary

The issue involves incorrect URL redirection in Next.js when using domain routing with i18n, where the Location header uses the wrong hostname. The fix requires understanding domain routing and i18n configuration, but the exact implementation scope is somewhat unclear due to the complexity of domain routing rules.

Issue Description

Link to the code that reproduces this issue

https://github.com/SLMNBJ/nextjs-domain-routing-redirect

To Reproduce

  1. npm run dev
  2. go to http://localhost:3000/en
  3. Click the blog link

Current vs. Expected behavior

Current: Next.js redirects to the wrong hostname. Location header URL uses the matched defaultLocale domain from i18n.domains to prefix the URL

Expected behavior: Next.js location header should use the current hostname I'm navigating for the location header. If I click http://localhost:3000/fr/will-be-removed/blog I expect to be http://localhost:3000/fr/blog

Screenshot 2024-08-01 at 10 37 21

Provide environment information

Node.js v18.20.3

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 23.6.0: Fri Jul  5 17:56:41 PDT 2024; root:xnu-10063.141.1~2/RELEASE_ARM64_T6000
  Available memory (MB): 16384
  Available CPU cores: 10
Binaries:
  Node: 18.20.3
  npm: 10.7.0
  Yarn: 1.22.19
  pnpm: N/A
Relevant Packages:
  next: 14.2.5 // Latest available version is detected (14.2.5).
  eslint-config-next: 14.2.5
  react: 18.3.1
  react-dom: 18.3.1
  typescript: 5.5.4
Next.js Config:
  output: N/A

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

Internationalization (i18n), Middleware, Navigation

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

next dev (local), next start (local)

Additional context

I have multiple environments with different domains. I use Domain Routing i18n to configure each domain's locale and add redirects to redirect old URLs to new ones.

<img width="959" alt="Screenshot 2024-08-01 at 10 46 48" src="https://github.com/user-attachments/assets/18592329-c386-4

GitHub Labels

bugMiddlewareLinking and NavigatingInternationalization (i18n)

Want to work on this?

Claim this issue to let others know you're working on it. You'll earn 20 points when you complete it!

Risk Flags

  • domain routing complexity
  • i18n configuration
Loading labels...

Details

Points20 pts
Difficultymedium
Scopesomewhat clear
Skill Matchmaybe
Test Focusedno