Skip to content

Commit a665493

Browse files
authored
fix(http): set headers on resposne manually (#1526)
The browser `Response` constructor removes `set-cookie` headers and so we set them manually. closes #1470
1 parent 77dfcb8 commit a665493

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

.changes/http-set-cookie.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"http-js": "patch"
3+
---
4+
5+
Fix missing `Set-Cookie` headers in the response which meant `request.headers.getSetCookie()` always returned empty array.

plugins/http/api-iife.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plugins/http/guest-js/index.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,16 @@ export async function fetch(
209209
},
210210
);
211211

212-
// url is read only but seems like we can do this
212+
// url and headers are read only properties
213+
// but seems like we can set them like this
214+
//
215+
// we define theme like this, because using `Response`
216+
// constructor, it removes url and some headers
217+
// like `set-cookie` headers
213218
Object.defineProperty(res, "url", { value: url });
219+
Object.defineProperty(res, "headers", {
220+
value: new Headers(responseHeaders),
221+
});
214222

215223
return res;
216224
}

0 commit comments

Comments
 (0)