https://github.com/frigus02/test-netlify-plugin-nextjs-cookies
https://github.com/frigus02/test-netlify-plugin-nextjs-cookies
Last synced: over 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/frigus02/test-netlify-plugin-nextjs-cookies
- Owner: frigus02
- Created: 2021-04-30T09:09:46.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2021-04-30T09:18:42.000Z (over 5 years ago)
- Last Synced: 2024-10-06T09:43:46.953Z (almost 2 years ago)
- Language: CSS
- Homepage:
- Size: 234 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# test-netlify-plugin-nextjs-cookies
It looks like multiple cookies are not correctly serialized when the browser sends multiple cookie headers over HTTP/2.
## Steps to reproduce
1. Test locally
```
yarn
yarn dev
```
Open http://localhost:3000/ and click on the button to generate 2 cookies. The site should reload and show `"first=1; second=2"`. Those are serialized correctly. You can see in the browser devtools that it uses HTTP/1.1.
2. Test on Netlify
```
export NETLIFY_SITE_ID=your_site_id
yarn
yarn deploy
```
Open deployed site and click on the button to generate 2 cookies. The site should reload and show `"first=1,second=2"`. Those are _not_ serialized correctly. They are separated by a comma instead of semicolon. You should see in the browser devtools that it uses HTTP/2.
## Investigation
We investigated further and saw in Wireshark, that browsers send multiple cookie headers when using HTTP/2:
```
cookie: first=1
cookie: second=2
```
but only 1 header with using HTTP/1.1:
```
cookie: first=1; second=2
```
This distinction is _not_ visible in browser devtools, sadly. But it seems to be according to the spec.
We think the code that serializes with a comma instead of semicolon is this line:
https://github.com/netlify/netlify-plugin-nextjs/blob/46526f955240dfcd1f65c4ecfa0c563ce2b1362d/src/lib/templates/createRequestObject.js#L64