-
-
Notifications
You must be signed in to change notification settings - Fork 253
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
Always resetting the cookie when a PWA is installed #527
Comments
I've had the same issue. I see you change locales using the |
@remcomulders Thanks for the reply! But even if setting prefetch to false, it doesn't work as expected when the PWA is installed on mobile. The cookie locale is always overridden by my system language on the first load. |
Thank you for your report! From the currently available context in this issue, it's unclear wether the erroneous behavior is caused by Next.js, If you're able to isolate the issue to Thank you for your understanding! |
Also make sure to upgrade to the latest version, e.g. 3.4.5 included a fix in regard to cookies. |
I've upgraded all the packages to the latest, and I'm still facing the issue that only happens with the I think that is because of the I can set a different cookie with the same value (and If so, would it be ok to change the SameSite cookie value? Thanks for the brilliant package. |
@amannn I can confirm. It's because of the Any hit of the app that starts outside of it will not be able to load the cookie for the first time by using That's why any installed PWA won't get the cookie value loaded and always is reset. The solution is to change from At the following URL, you will see that I settled two more cookies: https://intl-unable-find-locale.vercel.app/en Mystery solved. |
You're absolutely right @maiconsanson, thanks for investigating! #817 will address this, a fix should be out shortly. |
See https://web.dev/articles/samesite-cookies-explained#explicitly_state_cookie_usage_with_the_samesite_attribute for the rationale behind this. Fixes #527 Fixes #811
Thank you so much for putting this solution out here 🙏🏾. |
See https://web.dev/articles/samesite-cookies-explained#explicitly_state_cookie_usage_with_the_samesite_attribute for the rationale behind this. Fixes amannn#527 Fixes amannn#811
Description
Based on the docs, the main strategy to detect the locale is:
accept-language header
is matched against the available localesdefaultLocale
is usedThis happens very well when accessing a browser by URL.
But the strategy fails if I access my app, which is a PWA, from installed on mobile.
The
NEXT_LOCALE
cookie is resetting when the app opens based on theaccept-language header
, even if I have this cookie value already.Debugging my phone
If I access the root URL
/
, the previousNEXT_LOCALE
is ignored. The locale is alwaysen
because I'm using it as the default language on my phone.There is no problem with the app, only the
NEXT LOCALE
cookie is resetting. Other cookies are preserved and retrieved. In case I change my cellphone locale to Portuguese, the cookie is alwayspt
no matter what.Important
"next": "14.1.0"
"next-intl": "3.5.1"
"@serwist/next': '8.4.3"
'@serwist/sw': '8.4.3'
next-intl
update (I don't know which version) it did not happen.Mandatory reproduction URL (CodeSandbox or GitHub repository)
https://github.com/maiconsanson/next-intl-pwa-ignoring-cookie
Reproduction description
Steps to reproduce:
en
.en
, not the previouspt
selected.Repeat these steps directly on the browser and you seed that works normally.
Here is the production link to see in action:
https://intl-unable-find-locale.vercel.app/
Expected behaviour
The expected behavior is that the saved
NEXT_LOCALE
cookie value be used to define language when the PWA is installed.The text was updated successfully, but these errors were encountered: