mirror of
https://github.com/discourse/discourse.git
synced 2024-11-28 19:53:53 -06:00
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:
parent
6d1de26279
commit
f06be7d295
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user