-
Notifications
You must be signed in to change notification settings - Fork 27k
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
[NEXT-471] Calling cookies.set twice sets only one value, in API route with Edge runtime #38302
Comments
Please verify your issue reproduces with |
Note this issue still exists even when returning a Starting from export default function handler() {
const res = new Response();
res.headers.append('Set-Cookie', 'a=b');
res.headers.append('Set-Cookie', 'c=d');
return res;
}
export const config = {
runtime: 'experimental-edge',
}; Now, running
The expected behavior, when using |
I’ve verified that this bug still exists in the current |
Thanks for the tip, I've started to write a test case: #39132 |
Btw this seems vaguely related to whatwg/fetch#1346, it discusses the handling of list of set-header values in fetch. |
This issue still exists in Next.js 13. |
This issue still exists in Next.js 13.1, where edge API routes have been marked “stable.” |
This issue promoted me to store a stringified json object in a cookie. Not a great experience. |
Still a blocking problem here for introducing edge authentication... Not sure why the API is marked as stable when this issue persists into 2023. |
vercel/edge-runtime#255 needs to land first, then we can update Next.js as well |
Glad to see |
Getting the PR checks to pass. 😁 Working on it today. |
this seems still a issue even I upgrade to v13.2.1(which a fix has merged in v13.2.0), what did I miss? |
Confirmed ^ On export default function handler() {
const res = new Response('hey');
res.headers.append('Set-Cookie', 'a=b');
res.headers.append('Set-Cookie', 'c=d');
return res;
}
export const config = {
runtime: 'edge',
}; @balazsorban44 should this issue be reopened? |
@controversial could you open a new one with the above reproduction? 🙏 would be easier to track. |
By the way, it's a different (but related) issue, since you were not using |
@balazsorban44 Happy to open a new issue; will do that in a moment! I’m not sure this issue is solved either, though; This example uses the NextResponse API and is almost identical to the reproduction in the original issue: Only a single Set-Cookie header is returned. Is there a different test case associated with this issue that #42736 fixed? |
@balazsorban44 @controversial
from the spec:
comma is used in the Expires attribute value |
I think this issue should be reopened |
anyone know of a workaround for this issue that doesn't require turning a cookie into some JSON or an array? I'm trying to set cookies for a library that is pulling the cookies in a standard way. it's currently a blocker for me. thanks for any insights. |
Note that I don't have the option to reopen as issue creator, you might want to open a separate issue to get attention on this issue. |
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Verify canary release
Provide environment information
Not applicable, see reproduction here: https://codesandbox.io/s/condescending-torvalds-e3il3k?file=/package.json
What browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
Describe the Bug
Calling "cookies.set" twice on an API route with edge handler runtime will set only one cookie.
Expected Behavior
You'll see one "Set-Cookie" with 2 values, however it should be instead 2 "Set-Cookie" with only one value.
Set-Cookie can be repeated as many time as needed in an HTTP response to set multiple cookies. Edge middlewares do not suffer from this issue, it affects only API routes.
Link to reproduction
https://codesandbox.io/s/condescending-torvalds-e3il3k
To Reproduce
https://codesandbox.io/s/condescending-torvalds-e3il3k?file=/pages/index.tsx
Open index, check the Network tab for the "cookie" request.
NEXT-471
The text was updated successfully, but these errors were encountered: