Trailing slash appended to home page links when i18 and skipTrailingSlashRedirect - true #64929
Labels
bug
Issue was opened via the bug report template.
Internationalization (i18n)
Related to Internationalization with Next.js.
Link to the code that reproduces this issue
https://github.com/marcorcau/next-i18n-routing
To Reproduce
Test URL: https://next-i18n-routing-lac.vercel.app
http://localhost:3000
.http://localhost:3000/fr/
http://localhost:3000/gsp/first
http://localhost:3000/fr
. Notice link to english do not contain trailing slash, but german does.Current vs. Expected behavior
In steps 2 and 6, I would expect the "Locale switcher" links to not end in a slash, as any other link in the page or its sub-pages.
Provide environment information
Operating System: Platform: linux Arch: x64 Version: #1 SMP PREEMPT_DYNAMIC Debian 6.1.85-1 (2024-04-11) Available memory (MB): 15691 Available CPU cores: 16 Binaries: Node: 18.20.2 npm: 10.5.0 Yarn: 1.22.19 pnpm: 8.15.7 Relevant Packages: next: 14.2.2 // Latest available version is detected (14.2.2). eslint-config-next: N/A react: 18.2.0 react-dom: 18.2.0 typescript: 4.9.5 Next.js Config: output: N/A
Which area(s) are affected? (Select all that apply)
Internationalization (i18n)
Which stage(s) are affected? (Select all that apply)
next dev (local), next start (local)
Additional context
The code in the repo is exactly the same as the
next-i18n
example, just adding this line tonextConfig
:Any link to the home page in a language other than default gets a slash appended. This behaviour does not happen when linking to other pages.
In addition to this, when adding a
rewrites
section tonextConfig
or adding an emptymiddleware
and visiting the translated home page athttp://localhost:3000/fr
, a slash is also appended to the URL. It's not a redirect, its just appended after the page load.The "empty-middleware" and "rewrites" branches in the same repo reflect this issue, which is also triggered by adding
skipTrailingSlashRedirect: true,
to nextConfigThe text was updated successfully, but these errors were encountered: