-
-
Notifications
You must be signed in to change notification settings - Fork 483
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
No language redirect with dev with prefix
strategy in 'spa' mode
#677
Comments
If I understand it correctly, it's duplicate of #491 |
I also having this issue, but in a weird way. So I think I'll share my issue, in case it might help fixing this. I created a new installation of Nuxt and Nuxt-i18n, got the following version: My browser locale is This is my nuxt-i18n settings:
My workaround right now is, completely disable
|
@Bigdragon13th What you describe is indeed confusing so I would suggest you retest it in incognito/private window and with relevant ( With your configuration you should also consistently get 404 on |
No, sorry, I was wrong. But also the Nuxt This issue (as the github repo shows) is related to |
@rchl Thanks for the quick reply. Sorry, forgot to mention that I've tested this on incognito and have closed it to clear all cookies on every builds. My Nuxt mode setting is |
So redirection from 404 page doesn't work in Nuxt when done from a Nuxt plugin in SPA mode. Nuxt tries to push location using VueRouter but it gets "eaten" somewhere. This issue is in Nuxt and is what makes behavior inconsistent in SPA/Universal. While that inconsistency is on Nuxt, there is also a problem in @Bigdragon13th not sure what is happening then. It shouldn't be that inconsistent. :) |
Relevant Nuxt issue: nuxt/nuxt#4491 I will try to address the Nuxt issue (with a workaround) and the inconsistency in nuxt-i18n handling at the same time. |
Changes the `setLocale` logic to, in case current route is 404, to try to find a matching one for current locale. This is for situations when using `prefix` strategy where the root (`/`) route doesn't exist. We will try to find and redirect to prefixed route matching resolved locale. Also worked around Nuxt issue (nuxt/nuxt#4491 ) with `redirect` not working when called from a plugin in SPA mode. Required for the above fix above to be functional in SPA. Resolves #677 Resolves #491
Changes the `setLocale` logic to, in case current route is 404, to try to find a matching one for current locale. This is for situations when using `prefix` strategy where the root (`/`) route doesn't exist. We will try to find and redirect to prefixed route matching resolved locale. Also worked around Nuxt issue (nuxt/nuxt#4491 ) with `redirect` not working when called from a plugin in SPA mode. Required for the above fix above to be functional in SPA. Resolves #677 Resolves #491
prefix
strategyprefix
strategy in 'spa' mode
prefix
strategy in 'spa' modeprefix
strategy in 'spa' mode
prefix
strategy in 'spa' modeprefix
strategy in 'spa' mode
Thanks for the fix! However, it does seem that the issue also occurs for production builds with |
Do you mean when using SPA with |
@dokterbob also, there is no |
From quick testing, it seems to work for me (with But make sure to also specify your preferred browser languages and their order as that can make a difference. The |
@rchl Thanks for the quick feedback again. Indeed, I'm now doing a redirect in a It really does seem more sensible that, in the prefix scenario, an index route is generated which redirects to the user's preferred language. Until that is the case, I would suggest adding the information you just gave to the nuxt-i18n docs. Actually, I have found that the issues described in #700 occurs also when not using SPA, while using |
Version
nuxt-i18n: 6.9.2
nuxt: 2.0.0
Reproduction Link
https://github.com/dokterbob/i18nuxt-redirect-bug
Steps to reproduce
i18-nuxt
configured withstrategy
set to `prefix' as per documentation (refer to reproduction link)npm run dev
http://localhost:3000/
What is Expected?
A redirect to a language prefix (
/en/
or/pt/
).What is actually happening?
Page not found: "This page could not be found"
Notes
The problem also occurs in a production environment with
npm run build && npm run start
When using
rootRedirect
, the browser is redirected to the unprefixed route.When requesting a route different from the default (e.g.
/about/
) redirection is also not performed.Great care has been taken that browser cookies have been cleared in the tests above.
The text was updated successfully, but these errors were encountered: