Skip to content

Commit

Permalink
uses a for of instead of Object.fromEntries to preserve arrays in hea…
Browse files Browse the repository at this point in the history
…ders

This is necessary because the only way to set multiple cookies reliably from node is by writing a header like this:
'set-cookie': ['foo=bar', 'bar=baz']. Using Object.entries serializes the Array into a string which is not
what we want.
  • Loading branch information
merwan7 committed May 2, 2022
1 parent f461d27 commit 45e6a9f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/fuzzy-jeans-tickle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/hydrogen': patch
---

Adds ability to add multiple cookies in one response
5 changes: 4 additions & 1 deletion packages/hydrogen/src/entry-server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,10 @@ function getResponseOptions(
) {
const responseInit = {} as ResponseOptions;
// @ts-ignore
responseInit.headers = Object.fromEntries(headers.entries());
for (const key of headers.keys()) {
// @ts-ignore
responseInit.headers[key] = headers.raw()[key];
}

if (error) {
responseInit.status = 500;
Expand Down

0 comments on commit 45e6a9f

Please sign in to comment.