nextjs - ✅(Solved) Fix App Router routes return 404 when using Pages Router i18n with domain routing [1 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
vercel/next.js#86048Fetched 2026-04-08 02:12:48
View on GitHub
Comments
1
Participants
2
Timeline
12
Reactions
3
Timeline (top)
referenced ×4labeled ×3subscribed ×2commented ×1

Fix Action

Fixed

PR fix notes

PR #86116: Fix App Router 404 with Pages Router i18n domain routing

Description (problem / solution / changelog)

What?

When Pages Router uses domain-based i18n configuration, it was stripping locale prefixes from ALL requests, breaking App Router routes that need those prefixes for dynamic segments like [lang].

This fix detects when a path could match an App Router route with a dynamic locale segment and preserves the locale prefix for those routes while still stripping it for Pages Router routes.

How?

  • Add detect-app-router-locale-route utility with route matching
  • Fix locale stripping in base-server, next-server, resolve-routes
  • Add comprehensive unit tests (29 test cases)
  • Add e2e reproducer test demonstrating the fix

The fix allows both routers to coexist when middleware rewrites paths with locale prefixes for App Router consumption.

Fixes #86048

Changed files

  • packages/next/src/server/base-server.ts (modified, +134/-6)
  • packages/next/src/server/lib/i18n/detect-app-router-locale-route.test.ts (added, +284/-0)
  • packages/next/src/server/lib/i18n/detect-app-router-locale-route.ts (added, +102/-0)
  • packages/next/src/server/lib/router-utils/resolve-routes.ts (modified, +32/-0)
  • packages/next/src/server/next-server.ts (modified, +32/-2)
  • test/e2e/app-pages-i18n-domain-conflict/app-pages-i18n-domain.test.ts (added, +155/-0)
  • test/e2e/app-pages-i18n-domain-conflict/app/[lang]/page.tsx (added, +12/-0)
  • test/e2e/app-pages-i18n-domain-conflict/app/[lang]/test/page.tsx (added, +19/-0)
  • test/e2e/app-pages-i18n-domain-conflict/next.config.ts (added, +24/-0)
  • test/e2e/app-pages-i18n-domain-conflict/pages/index.tsx (added, +29/-0)
  • test/e2e/app-pages-i18n-domain-conflict/proxy.ts (added, +63/-0)

Code Example

127.0.0.1 en.example.local
127.0.0.1 nl.example.local

---

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 25.1.0: Mon Oct 20 19:34:05 PDT 2025; root:xnu-12377.41.6~2/RELEASE_ARM64_T6041
  Available memory (MB): 49152
  Available CPU cores: 14
Binaries:
  Node: 22.11.0
  npm: 10.9.0
  Yarn: 1.22.22
  pnpm: 8.7.0
Relevant Packages:
  next: 16.0.1 // Latest available version is detected (16.0.1).
  eslint-config-next: N/A
  react: 19.2.0
  react-dom: 19.2.0
  typescript: 5.9.3
Next.js Config:
  output: N/A
RAW_BUFFERClick to expand / collapse

Link to the code that reproduces this issue

https://github.com/RobVermeer/nextjs-i18n-domain-routing-issue

To Reproduce

  1. Clone the reproduction repository: https://github.com/RobVermeer/nextjs-i18n-domain-routing-issue
  2. Add to /etc/hosts:
127.0.0.1 en.example.local
127.0.0.1 nl.example.local
  1. Run npm install && npm run dev
  2. Visit http://nl.example.local:3000/ - Pages Router works correctly
  3. Visit http://nl.example.local:3000/test - Returns 404

Current vs. Expected behavior

Current: App Router routes return 404 when Pages Router i18n domain configuration is present in next.config.ts. The proxy.ts successfully rewrites /test to /nl-NL/test, but the route is not resolved.

Expected: Both routers should coexist with domain-based i18n routing. App Router routes should work alongside Pages Router i18n configuration.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 25.1.0: Mon Oct 20 19:34:05 PDT 2025; root:xnu-12377.41.6~2/RELEASE_ARM64_T6041
  Available memory (MB): 49152
  Available CPU cores: 14
Binaries:
  Node: 22.11.0
  npm: 10.9.0
  Yarn: 1.22.22
  pnpm: 8.7.0
Relevant Packages:
  next: 16.0.1 // Latest available version is detected (16.0.1).
  eslint-config-next: N/A
  react: 19.2.0
  react-dom: 19.2.0
  typescript: 5.9.3
Next.js Config:
  output: N/A

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

Internationalization (i18n), Dynamic Routes, Pages Router

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

next dev (local), next build (local), next start (local), Other (Deployed), Vercel (Deployed)

Additional context

  • The issue only occurs when i18n config with domains is present in next.config.ts
  • Removing the i18n config makes App Router work but breaks Pages Router domain routing
  • The proxy correctly detects the domain and performs the rewrite (confirmed via logs)
  • Next.js 16.0.1, React 19.2.0

extent analysis

TL;DR

The issue can be resolved by adjusting the next.config.ts file to properly configure the App Router and Pages Router to coexist with domain-based i18n routing.

Guidance

  • Review the next.config.ts file to ensure that the i18n configuration with domains is correctly set up for both App Router and Pages Router.
  • Verify that the proxy.ts file is correctly rewriting the URLs for the App Router routes.
  • Check the Next.js documentation for any specific configuration requirements for using App Router and Pages Router together with i18n domain routing.
  • Consider testing the application with a simplified next.config.ts file to isolate the issue and identify any potential configuration conflicts.

Example

No code example is provided as the issue is related to configuration and not a specific code snippet.

Notes

The issue seems to be related to the configuration of Next.js and the interaction between App Router, Pages Router, and i18n domain routing. The provided information suggests that the issue is specific to the next.config.ts file and the proxy.ts file.

Recommendation

Apply workaround: Adjust the next.config.ts file to properly configure the App Router and Pages Router to coexist with domain-based i18n routing, as the issue is likely related to a configuration conflict.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

nextjs - ✅(Solved) Fix App Router routes return 404 when using Pages Router i18n with domain routing [1 pull requests, 1 comments, 2 participants]