DEV: Fix multiple set-cookie through Ember-CLI proxy (#19316)

The `Set-Cookie` header is an exceptional case where multiple values are allowed, and should not be joined into a single header. Because of its browser-focussed origins (where set-cookie is not visible), `fetch()` does not have a clean API for this. Instead we have to access the `raw()` data.

This fixes various authentication-related issues when developing via the Ember CLI proxy.
This commit is contained in:
David Taylor 2022-12-05 15:01:55 +00:00 committed by GitHub
parent 6d1de26279
commit f06be7d295
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 1 deletions

View File

@ -319,7 +319,13 @@ async function handleRequest(proxy, baseURL, req, res) {
});
response.headers.forEach((value, header) => {
res.set(header, value);
if (header === "set-cookie") {
// Special handling to get array of multiple Set-Cookie header values
// per https://github.com/node-fetch/node-fetch/issues/251#issuecomment-428143940
res.set("set-cookie", response.headers.raw()["set-cookie"]);
} else {
res.set(header, value);
}
});
res.set("content-encoding", null);