You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
i18n: {// ... base config ...strategy: 'prefix',},
If your browser locale is set to nl and you navigate to /, the following will happen:
the logs will detect nl is your browser locale
not redirected anywhere (stays on /) [1]
ends with a 302 Found status code [2]
locale wrongly set to en instead of nl [3]
cookie wrongly set to en instead of nl [4]
[1] although from the docs I understand the prefix strategy should redirect to the correct locale.
[2] which is not good for SEO and just in general unexpected I guess
[3] I don't know why this would happen
[4] I don't understand when a cookie will be or will not be set (see example 2. also)
2.
with the following settings:
i18n: {// ... base config ...detectBrowserLanguage: {alwaysRedirect: true,},strategy: 'prefix',},
If your browser locale is set to nl and you navigate to /, the following will happen:
the logs will detect nl is your browser locale
not redirected anywhere (stays on /) [1]
ends with a 302 Found status code [2]
locale correctly set to nl
no cookie will be set [5]
[5] Weird because in the previous example, it was set (incorrectly, but that doesn't matter here for now). So I think it's unexpected to not set it here.
Environment
v16.14.2
3.2.0
2.2.1
vite
ssr
,modules
,i18n
,typescript
@nuxtjs/[email protected]
-
Reproduction
https://stackblitz.com/edit/github-8hn8cb
Describe the bug
I think there's quite some inconsistencies/unclarity in this plugin regarding redirection and locale detection.
For the rest of this issue, suppose we have the following base config set:
A few examples:
1.
with the following settings:
If your browser locale is set to
nl
and you navigate to/
, the following will happen:nl
is your browser locale/
) [1]302 Found
status code [2]en
instead ofnl
[3]en
instead ofnl
[4][1] although from the docs I understand the
prefix
strategy should redirect to the correct locale.[2] which is not good for SEO and just in general unexpected I guess
[3] I don't know why this would happen
[4] I don't understand when a cookie will be or will not be set (see example 2. also)
2.
with the following settings:
If your browser locale is set to
nl
and you navigate to/
, the following will happen:nl
is your browser locale/
) [1]302 Found
status code [2]nl
[5] Weird because in the previous example, it was set (incorrectly, but that doesn't matter here for now). So I think it's unexpected to not set it here.
3.
with the following settings:
If your browser locale is set to
nl
and you navigate to/foobar
, the following will happen:nl
is your browser locale/foobar
) [1]302 Found
status code [2]en
instead ofnl
[6]en
instead ofnl
[4][6] Which is weird, because as we saw in the previous example, for the root it was correctly set to
nl
Additional context
Maybe these examples should have been split up into separate issues. But I'm not sure if they are or are not related to each other.
Logs
No response
The text was updated successfully, but these errors were encountered: