nuxt-modules / i18n

I18n module for Nuxt
https://i18n.nuxtjs.org
MIT License
1.75k stars 483 forks source link

Redirect fails with 404 error for non-index pages if SSR is turned off #3030

Open alexblunck opened 4 months ago

alexblunck commented 4 months ago

Environment

Reproduction

https://github.com/alexblunck/nuxt-i18n-bug-reproduction

(I've provided a Fork of the "Reproduction starter" since Stackblitz doesn't seem to support redirects)

Describe the bug

When SSR is turned off and strategy: 'prefix' is used together with redirectOn: 'no prefix' the redirect on initial page loads fails & displays a "404 Page not found" error.

This only happens for non-index pages. To trigger the error in the Reproduction visit http://localhost:3000/other. The URL in the address bar does change to http://localhost:3000/en/other but application crashes and displays "Page not found: /other" error.

Additional context

No response

Logs

No response

spreadpando commented 4 months ago

After npx nuxi upgrade -f I am encountering this issue as well but for index '/' routes as well:

nuxt.js:118 [nuxt] error caught during app initialization Error: Page not found: /

the url bar is updated, but the page shows 404.

Refreshing the page with the complete url works as expected.

Unfortunately, reverting to @nuxtjs/i18n@8.0.0 did not resolve the issue so it seems like a nuxt redirect issue.

Perhaps related to: https://github.com/nuxt/nuxt/issues/27903