-
Notifications
You must be signed in to change notification settings - Fork 554
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
fix(cloudflare): split Set-Cookie
header into multiple headers
#989
Conversation
I suppose that these changes should be applied also to other presets where |
Codecov Report
@@ Coverage Diff @@
## main #989 +/- ##
==========================================
- Coverage 76.64% 67.66% -8.98%
==========================================
Files 71 60 -11
Lines 7241 6161 -1080
Branches 723 692 -31
==========================================
- Hits 5550 4169 -1381
- Misses 1690 1982 +292
- Partials 1 10 +9 |
I checked codebase a little bit deeper and i think that it should be changed on unenv level and |
src/runtime/entries/cloudflare.ts
Outdated
|
||
for (const [k, v] of Object.entries(headers)) { | ||
if (k === "set-cookie") { | ||
for (const cookie of splitCookiesString(v)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have recently introduced same util in h3. It might be one less dependency and bundle size if we expose it from h3 package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, what is proper way to sync versions of h3 and current nitro? Should we wait for h3 version tag or?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, releasing next version until this weekend. (at the same time thinking about your other comments, we need to really fix header normalization across entries)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As i see normalize function looks same for all other entries, but i think something is different on provider level, i suppose that some of them do cookie splitting themselves. We can drop normalize function to utils and use it every entry until make changes with type change for HadersObject
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed there are slight behavior diferences. Also we never properly tested header behavior on nitro-deploys π
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello, @pi0. Do you have any plans for releasing new versions soon? Gonna continue work on module and project, but this issue blocks me testing any env except local one :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, dear @oleghalin. Sure. I am (at the moment!) trying workers via pages on nitro-deploys. That would make testing this PR possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, just in case wanna remind that it also waits for unjs/h3 release for splitCookieString helper :)
Set-Cookie
header into multiple headers
Hello, @pi0 any updates on it? Issue with Set-Cookie header and 404 caching its making Nuxt absolutely unusuable with Cloudlare Workers |
Hey @oleghalin, I noticed that the new |
Hello, @pi0. I just just updated my PR and dropped third-party dep |
Hey, @pi0. I suppose that it makes many problems for all users who use CF workers to deploy, can you take a look on it? It solves 2 big problems with caching and cookies |
+1 I had the same bug that bothered me for daysοΌit's not just about |
β¦h cookie sent from proxy
@oleghalin This is on my radar, apologies for the delay. Can you provide me with a reproduction ? I would like to see if this behaviour affects the other cloudflare presets too. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't include any tests or reproduction, so this is hard to test.
Not sure why you need reproduction, Set-Cookie header should be merged into one because browsers read each Set-Cookie header and set 1 cookie per each Set-Cookie header, as soon as there is only 1 header delimited by coma it will write only first cookie. As I know Vercel and node server parse it on their end and thats why it works, but it doesn't work for CF. |
Thanks for the additional information and the PR. |
Cannot make repro right now, but referencing RFC for you to understand it better. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is absolutely a necessary change!
-
The check for publicAsset needs to happen in another PR perf(cloudflare): check for asset urlΒ #1236 (feedback welcome)
-
This affects multiple preset and needs to be applied everywhere
); | ||
|
||
// Fetch public assets from KV only | ||
if (isPublicAssetURL(id)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree this needs to happen, but it should be handled in a different PR (https://github.com/unjs/nitro/pull/1236/files)
π Linked issue
#988
β Type of change
π Description
Splits Set-Cookie for each upstream header provided.
Resolves #988
π Checklist