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

Trailing slash appended to home page links when i18 and skipTrailingSlashRedirect - true #64929

Open
marcorcau opened this issue Apr 23, 2024 · 0 comments · May be fixed by #64931
Open

Trailing slash appended to home page links when i18 and skipTrailingSlashRedirect - true #64929

marcorcau opened this issue Apr 23, 2024 · 0 comments · May be fixed by #64931
Labels
bug Issue was opened via the bug report template. Internationalization (i18n) Related to Internationalization with Next.js.

Comments

@marcorcau
Copy link

marcorcau commented Apr 23, 2024

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

  1. Start the application in development (pnpm run dev) in default language http://localhost:3000.
  2. Hover on the "Locale switcher" links, notice urls end in a slash as in http://localhost:3000/fr/
  3. Hover on the other links, notice they don't end in a slash, as in http://localhost:3000/gsp/first
  4. Click on any of the "To XXXXX page" link except "To Index page").
  5. Hover on any of the "Locale switcher" links, notice urls do not end in a slash.
  6. Visit french home page at 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 to nextConfig:

  skipTrailingSlashRedirect: true,

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 to nextConfig or adding an empty middleware and visiting the translated home page at http://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 nextConfig

@marcorcau marcorcau added the bug Issue was opened via the bug report template. label Apr 23, 2024
@github-actions github-actions bot added the Internationalization (i18n) Related to Internationalization with Next.js. label Apr 23, 2024
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. Internationalization (i18n) Related to Internationalization with Next.js.
Projects
None yet
1 participant