amannn / next-intl

🌐 Internationalization (i18n) for Next.js
https://next-intl-docs.vercel.app
MIT License
2.58k stars 236 forks source link

Trailing Slash does not work from address bar when enabled Static Export #1358

Closed zulalnb closed 1 month ago

zulalnb commented 1 month ago

Description

When enabled static export and trailing slash together, URL in the internal links redirects to the version with trailing slash, but in the address bar does not.

Verifications

Mandatory reproduction URL

https://github.com/zulalnb/next-intl-static-export-trailing-slash-issue

Reproduction description

Steps to reproduce:

  1. type git clone https://github.com/zulalnb/next-intl-static-export-trailing-slash-issue.git
  2. type npm install
  3. type npm run build
  4. type npx serve@latest out
  5. open http://localhost:3000/
  6. enter http://localhost:3000/en/sub in the address bar manually

Expected behaviour

I expected to ensure that entering a URL directly in the address bar redirects to the version with a trailing slash.

amannn commented 1 month ago

This depends on your web server config. In your case, serve doesn't ensure a trailing slash.

An alternative like http-server does this however, redirecting /en/sub to /en/sub/.

npx http-server out