Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I18n breaks when using a middleware #58583

Open
1 task done
cornedor opened this issue Nov 17, 2023 · 4 comments · May be fixed by #61561
Open
1 task done

I18n breaks when using a middleware #58583

cornedor opened this issue Nov 17, 2023 · 4 comments · May be fixed by #61561
Labels
bug Issue was opened via the bug report template. Navigation Related to Next.js linking (e.g., <Link>) and navigation. Runtime Related to Node.js or Edge Runtime with Next.js.

Comments

@cornedor
Copy link

cornedor commented Nov 17, 2023

Link to the code that reproduces this issue

https://github.com/cornedor/i18n-routing-bug

To Reproduce

Create a next app with:

  1. i18n configured
  2. a middleware (the middleware doesn't have to do anything or match the requested paths)
  3. A page with getStaticProps

When clicking a Next link:

  1. the getStaticProps function in the requested page will receive an incorrect locale.
  2. The x-nextjs-matched-path header shows the same incorrect locale
Screen.Recording.2023-11-17.at.12.23.28.mov

Current vs. Expected behavior

When clicking the link, the correct locale will be used.

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 23.1.0: Mon Oct  9 21:28:45 PDT 2023; root:xnu-10002.41.9~6/RELEASE_ARM64_T6020
Binaries:
  Node: 18.18.2
  npm: 9.8.1
  Yarn: 1.22.19
  pnpm: N/A
Relevant Packages:
  next: 14.0.4-canary.1
  eslint-config-next: 14.0.3
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.2.2
Next.js Config:
  output: N/A

Also tested in:

  • 14.0.4-canary.6
  • 14.1.1-canary.13

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

Internationalization (i18n), Middleware / Edge (API routes, runtime), Routing (next/router, next/navigation, next/link)

Additional context

This seems to be an issue with all 14.0.x versions.

@cornedor cornedor added the bug Issue was opened via the bug report template. label Nov 17, 2023
@github-actions github-actions bot added Runtime Related to Node.js or Edge Runtime with Next.js. Navigation Related to Next.js linking (e.g., <Link>) and navigation. labels Nov 17, 2023
@cornedor
Copy link
Author

This is still broken in 14.1.1-canary.13

@cornedor
Copy link
Author

cornedor commented Feb 1, 2024

Maybe related to: #61201

@cornedor
Copy link
Author

cornedor commented Feb 1, 2024

I have a workaround that only works when middleware is enabled, still looking for the real issue: cornedor@14a2417

@cornedor cornedor linked a pull request Feb 2, 2024 that will close this issue
@jaosn60810
Copy link

meet same issue at "next": "14.0.4",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue was opened via the bug report template. Navigation Related to Next.js linking (e.g., <Link>) and navigation. Runtime Related to Node.js or Edge Runtime with Next.js.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants