-
-
Notifications
You must be signed in to change notification settings - Fork 490
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
Inconsistent handling of Accept-Language
header
#2524
Comments
To redirect using cookies or the Disabling browser language detection has some other behavior that seems a bit unintuitive with the |
Thanks for the feedback, and for the work on #2538 !
In my use case, the first path segment MUST be the language, and since I'll do some testing with #2538 and give you my feedback, as soon as I can. |
I tried #2538 and it seems to make no difference at all. |
I updated my repro at https://stackblitz.com/edit/github-fyaxh8 :
Results:
Note that there are no catch-all routes in this example! |
By the way, |
Further debugging revealed the following underlying causes:
|
I think the underlying problem to all of this is that a lot of checks that are happening in the In fact, just commenting out this part of
This should probably be replaced by something like this at the top of the route middleware:
|
I think you will get the same results when setting |
As I have said many times before, I do NOT want |
I'm asking you whether the changes you made would still result in the same behavior |
Sorry for misunderstanding your question, and for my impatience! To be honest, I'm still not sure what you are asking. You wrote:
Does "this change" refer to
|
You said that commenting out part of The confusion for me is, this issue is titled "Inconsistent handling of Accept-Language header", but you're experiencing 2 separate (though related) issues. 1. Inconsistent handling of
|
Sorry, I looked at this again, and I was mistaken! Commenting out this part in
caused some other bugs, so that was a bad idea. This is because However, adding something like this at the top of the middleware does solve my problem: const redirectOn = nuxtI18nOptions.detectBrowserLanguage?.redirectOn;
if (redirectOn == "root" && to.path !== "/") {
console.log("Skipping locale-changing middleware because were not on the root path.")
return;
}
if (redirectOn == "no prefix" && ... etcetera ... ) {
// Not implemented yet because I'm not using redirectOn == "no prefix"
console.log("Skipping locale-changing middleware because ...");
return;
} It solves the problem by preventing the middleware from running when it should not. This, together with the changes of #2538 solves both #2131 and this issue. |
close with #2538 |
Updated reproductionhttps://stackblitz.com/edit/github-fyaxh8 Steps to reproduce
ResultsCorrect
Incorrect
This is wrong, because there is no /foo route, so it should give Proposed solutionAdd something like this at the top of the route middleware in const redirectOn = nuxtI18nOptions.detectBrowserLanguage?.redirectOn;
if (redirectOn == "root" && to.path !== "/") {
console.log("Skipping locale-changing middleware because were not on the root path.")
return;
}
if (redirectOn == "no prefix" && ... etcetera ... ) {
// Not implemented yet because I'm not using redirectOn == "no prefix"
console.log("Skipping locale-changing middleware because ...");
return;
} It solves the problem by preventing the middleware from running when it should not. Here is the patch I'm currently using with
|
Update 2024/01/02
See updated reproduction and steps to reproduce at #2524 (comment)
Environment
Working directory: /home/projects/aoniwxvlm.github 13:55:30
Nuxt project info: 13:55:30
Reproduction
https://stackblitz.com/edit/github-fyaxh8
Describe the bug
The root redirect takes the
Accept-Language
header into account:But everything else does not:
This also relates to #2131 because I'm using the
prefix
strategy, which means I should actually get a 404 on the/foo
request. Therefore, I think fixing #2131 will also fix this issue, but not vice versa.Additional context
No response
Logs
No response
The text was updated successfully, but these errors were encountered: