-
Notifications
You must be signed in to change notification settings - Fork 82
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
Unable to set multiple cookies from within service method handler #745
Comments
Hey Tim, good call. Special handling of the The feature was subsequently added to undici (the fetch implementation of Node.js) in v5.19.0. Node 18 updated to this version of undici in v18.14.1: $ fnm exec --using=v18.14.0 node t.mjs
getSetCookie: unavailable
forEach: custom: a, b
forEach: set-cookie: a=a; Expires=Wed, 21 Oct 2015 07:28:00 GMT, b=b; Expires=Wed, 21 Oct 2015 07:28:00 GMT $ fnm exec --using=v18.14.1 node t.mjs
getSetCookie: [
'a=a; Expires=Wed, 21 Oct 2015 07:28:00 GMT',
'b=b; Expires=Wed, 21 Oct 2015 07:28:00 GMT'
]
forEach: custom: a, b
forEach: set-cookie: a=a; Expires=Wed, 21 Oct 2015 07:28:00 GMT
forEach: set-cookie: b=b; Expires=Wed, 21 Oct 2015 07:28:00 GMT Node 16 got the update in v16.19.1: $ fnm exec --using=v16.19.0 node --experimental-fetch t.mjs
getSetCookie: unavailable
forEach: custom: a, b
forEach: set-cookie: a=a; Expires=Wed, 21 Oct 2015 07:28:00 GMT, b=b; Expires=Wed, 21 Oct 2015 07:28:00 GMT $ fnm exec --using=v16.19.1 node --experimental-fetch t.mjs
getSetCookie: [
'a=a; Expires=Wed, 21 Oct 2015 07:28:00 GMT',
'b=b; Expires=Wed, 21 Oct 2015 07:28:00 GMT'
]
forEach: custom: a, b
forEach: set-cookie: a=a; Expires=Wed, 21 Oct 2015 07:28:00 GMT
forEach: set-cookie: b=b; Expires=Wed, 21 Oct 2015 07:28:00 GMT Node 20 had it from the start. t.mjsconst h = new Headers();
h.append("Custom", "a");
h.append("Custom", "b");
h.append("Set-Cookie", "a=a; Expires=Wed, 21 Oct 2015 07:28:00 GMT");
h.append("Set-Cookie", "b=b; Expires=Wed, 21 Oct 2015 07:28:00 GMT");
if ("getSetCookie" in h && typeof h.getSetCookie == "function") {
const setCookies = h.getSetCookie();
console.log("getSetCookie:", setCookies);
} else {
console.log("getSetCookie: unavailable");
}
h.forEach((value, key) => {
console.log(`forEach: ${key}: ${value}`);
});
We should definitely support the new handling of the header. We might want to switch our polyfill to use undici. |
For posterity:
We just did in #791. |
Describe the bug
We are using @bufbuild/connect-express to connect to an express application, but cannot create multiple set-cookie headers to enable browsers to set multiple cookies based on response. For this header in particular, we need the ability to set separate headers with same key instead of combining into single value.
To Reproduce
Simply try appending multiple values to
ctx.responseHeader
from within a service handler, and only one header gets sets. Trying to set once with multiple values fails as well.Environment (please complete the following information):
0.9.1
0.9.1
angular@14.1.0
18.16.0
Google Chrome 115.0.5790.170
The text was updated successfully, but these errors were encountered: