-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Can't set multiple cookies in response on v2 #6525
Comments
Hello! What version of Node are you using? We've recently had a whole dilemma around cookie handling where specific versions of Node behaved differently and stuff, so it would be helpful to know! |
ah, i see. i was using node 18.2, it working after upgrade to 18.5 |
I'm using 18.12 and have the same problem here. Edited: only in dev mode. Using production mode (after build, using @astrojs/node) works fine |
Please reopen the issue, I am having the same problem as @jeffdrumgod. Setting multiple cookies works in build but not in dev. Really makes it impossible to use cookies while developing. Running Edit: |
Ok, will recheck. |
Think a regression happened here. https://github.com/withastro/astro/pull/6355/files |
I'm seeing multiple set-cookie's work in dev and not in prod (nodejs adapter) using current Node LTS v18.16.0 and latest Astro 2.5.5 I'm not even using Astro.cookies at all, this is me directly setting up a Response with a Headers object with multiple set-cookie headers, e.g. const h = new Headers();
h.append("set-cookie", "cookie1=abc");
h.append("set-cookie", "cookie2=abc");
return new Response("abc", { headers }); Works in dev, but in prod (using Astro's nodejs adapter) only the first set-cookie is used. Feels like a bug with some naive code grabbing only the first occurrence of a key (e.g. "set-cookie" header name), still digging through Astro code to see if I can find the culprit |
And there it is https://github.com/withastro/astro/blob/main/packages/integrations/node/src/nodeMiddleware.ts#L52 res.writeHead(status, Object.fromEntries(headers.entries())); The line In reading the node spec for So this needs to be smarter about building a multi-value object of header key/value pairs Since this issue was about Astro cookies (and what I'm referring to is the nodejs adapter for any headers specifically set on the |
Multiple set-cookie headers is not supported by the Headers API. If you Google you'll see lots of discussion on this. |
What version of
astro
are you using?2.1.2
Are you using an SSR adapter? If so, which one?
tried on vercel and node
What package manager are you using?
pnpm
What operating system are you using?
Mac
What browser are you using?
Chrome
Describe the Bug
Link to Minimal Reproducible Example
todo
Participation
The text was updated successfully, but these errors were encountered: