-
Notifications
You must be signed in to change notification settings - Fork 86
[Bug]: redirecting the user to a localized version of the page does not depend on Accept-Language header and NEXT_LOCALE cookie #788
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
Comments
I've asked the customer for the repo. Waiting for their response. |
There is an internal note in https://netlify.zendesk.com/agent/tickets/72892 that indicates we might have a testable repo, but since I wasn't involved in creating I'd want @kaganjd or @hrishikesh-k to confirm my guess that that is for this issue, before any work gets done using it. |
Yeah if it's the latest comment by Jen that you're talking about, then that's related. |
So as per the slack thread (internal), this bug is fixed in v4 of the plugin. We do not expect to fix this in v3 as it is not trivial 😞. A workaround in v3 until the beta is stable would be:
Code snippet for option 1You may have to add this to every page export async function getServerSideProps(context) {
const acceptLanguageHeader = context?.req?.headers['accept-language']
const nextLocaleCookie = context?.req?.cookies?.NEXT_LOCALE
// Force the locale to be either the NEXT_LOCALE cookie or the Accept-Language header
const locale = nextLocaleCookie
? nextLocaleCookie
: acceptLanguageHeader
? acceptLanguageHeader
: context?.req?.locale || "";
return {
props: {
locale
},
}
} Example repo and deploy previewExample repo with v3 of the plugin: tiffafoo/next-netlify-starter#2 If you'd like to see the header and cookie working in the beta version, you can look at the main branch of the above repo. The deploy preview for v4 can be found here cc @wein-hillary @hrishikesh-k @dendeli-work @MelvinPeepers |
Thanks for the quick fix! |
See #788 (comment) for resolution and workaround in v3.
Context
This is a bug that happens in version 3. The beta version of the plugin works as expected
If a user prefers the locale
fr
in theirAccept-Language
header but has aNEXT_LOCALE=en
cookie set to theen
locale, when visiting/
the user should be redirected to theen
locale location until the cookie is removed or expired. (next docs on this here). Some users are reporting that the cookie and header are not working as expected.https://netlify.zendesk.com/agent/tickets/71454
https://netlify.zendesk.com/agent/tickets/72892
In another thread:
Steps to reproduce
Repro steps
/
A link to a reproduction repository
https://github.com/tiffanosaurus/next-netlify-starter/tree/test
More information about your build
What OS are you using?
N/A deployed via netlify
Your
netlify.toml
filehttps://github.com/tiffanosaurus/next-netlify-starter/blob/test/netlify.toml
Relevant log output (or link to your logs)
https://app.netlify.com/sites/vigorous-lalande-d32aae/deploys/618e898787cc54da77e495ee
The text was updated successfully, but these errors were encountered: