next.js icon indicating copy to clipboard operation
next.js copied to clipboard

Path based cookies not visible on route change

Open GetafixIT opened this issue 2 years ago • 0 comments

Verify canary release

  • [X] I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
  Platform: darwin
  Arch: x64
  Version: Darwin Kernel Version 21.6.0: Mon Aug 22 20:17:10 PDT 2022; root:xnu-8020.140.49~2/RELEASE_X86_64
Binaries:
  Node: 16.17.0
  npm: 8.15.0
  Yarn: 1.22.10
  pnpm: 6.11.5
Relevant packages:
  next: 13.0.2
  eslint-config-next: N/A
  react: 18.2.0
  react-dom: 18.2.0

What browser are you using? (if relevant)

chrome, firefox, safari

How are you deploying your application? (if relevant)

N/A

Describe the Bug

I have a cookie, is has a path configuration of /ie/ so should be viable for the domain on any URL starting with that.

image

I have i18n rules in place. The route of the app is configured as per the default route. From this page you can choose the locale you would like to browse the app in.

Using Next Link, I navigate to a path with locale ( /ie ). But no cookies are visible.

Refresh the page and cookies are now visible to the browser.

The browser isn't aware the path has changed and therefore new path specific cookies should be viable.

I made an example app, linked above. You can run this locally, in any browser and see the same result.

Expected Behavior

Path based cookies should be available on route change.

Link to reproduction

https://github.com/GetafixIT/next-locale-cookie-bug

To Reproduce

next dev

Open in a browser, follow instructions.

GetafixIT avatar Nov 04 '22 17:11 GetafixIT