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

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

Open
alexblunck opened this issue Jul 15, 2024 · 2 comments
Open

Comments

@alexblunck
Copy link

Environment

  • Operating System: Darwin
  • Node Version: v20.15.1
  • Nuxt Version: 3.12.3
  • CLI Version: 3.12.0
  • Nitro Version: 2.9.7
  • Package Manager: [email protected]
  • Builder: -
  • User Config: modules, devtools, ssr, i18n
  • Runtime Modules: @nuxtjs/[email protected]
  • Build Modules: -

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
Copy link

spreadpando commented Jul 19, 2024

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/[email protected] did not resolve the issue so it seems like a nuxt redirect issue.

Perhaps related to:
nuxt/nuxt#27903

@adasek
Copy link

adasek commented Feb 8, 2025

Hi, I'm encountering a similar issue as well. It broke for me between v8.0.0-rc.6 and v8.0.0-rc.7

It seems to me the combination of
includeUnprefixedFallback = options.strategy !== 'prefix' with this condition check for options.strategy == 'prefix' && options.includeUnprefixedFallback makes it impossible to ever enter the condition body with localizedRoutes.push({ ...route, locale, parent }).

However, I experimented with fixing this, but it didn't solve the problem. The root index page is still not generated when I do nuxt generate and nuxt dev is giving me WARN [Vue Router warn]: No match found for location with path "/"

My versions are [email protected], @nuxt/[email protected], @nuxtjs/[email protected]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants