Skip to content

fix: Make sure cookie value stays up to date when the Next.js Router Cache is used - #790

Merged
amannn merged 6 commits into
mainfrom
fix/786-consistent-cookie
Jan 19, 2024
Merged

fix: Make sure cookie value stays up to date when the Next.js Router Cache is used#790
amannn merged 6 commits into
mainfrom
fix/786-consistent-cookie

Conversation

@amannn

@amannn amannn commented Jan 18, 2024

Copy link
Copy Markdown
Owner

Fixes #786

If you frequently change the locale, Next.js will at some point use the Router Cache to return a previous response immediately, not making a request to the server. This has the side effect that no set-cookie response header is returned that will update the locale cookie.

To address this, next-intl navigation APIs will now manually keep the cookie in sync.

Note that a related issue described in #786 was addressed in Next.js 14.1, so upgrading both next and next-intl is recommended.

@vercel

vercel Bot commented Jan 18, 2024

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
next-intl-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 19, 2024 10:10am
next-intl-example-app-router ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 19, 2024 10:10am

@amannn
amannn merged commit 977b973 into main Jan 19, 2024
@amannn
amannn deleted the fix/786-consistent-cookie branch January 19, 2024 10:22
juanforlizzi pushed a commit to juanforlizzi/next-intl that referenced this pull request Jan 16, 2025
…Cache is used (amannn#790)

Fixes amannn#786

If you frequently change the locale, Next.js will at some point use the
Router Cache to return a previous response immediately, not making a
request to the server. This has the side effect that no `set-cookie`
response header is returned that will update the locale cookie.

To address this, `next-intl` navigation APIs will now manually keep the
cookie in sync.

Note that a related issue described in amannn#786 was addressed in Next.js
14.1, so upgrading both `next` and `next-intl` is recommended.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

With LocalePrefix: 'never' locale switches to previous choice on navigating app pages

1 participant