Skip to content

Commit

Permalink
fix: use headers.entries() instead of headers.raw()
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelDeBoey committed Aug 16, 2023
1 parent c4dad59 commit 0689d14
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 15 deletions.
7 changes: 7 additions & 0 deletions .changeset/orange-suits-nail.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@remix-run/architect": patch
"@remix-run/express": patch
---

- Switch to `headers.entries()` instead of non-spec-compliant `headers.raw()` in `sendRemixResponse`
- Update to `@remix-run/[email protected]`
4 changes: 3 additions & 1 deletion packages/remix-architect/__tests__/server-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,9 @@ describe("architect createRemixHeaders", () => {
describe("creates fetch headers from architect headers", () => {
it("handles empty headers", () => {
let headers = createRemixHeaders({});
expect(headers.raw()).toMatchInlineSnapshot(`Object {}`);
expect(Object.fromEntries(headers.entries())).toMatchInlineSnapshot(
`Object {}`
);
});

it("handles simple headers", () => {
Expand Down
6 changes: 2 additions & 4 deletions packages/remix-architect/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,9 @@ export async function sendRemixResponse(
let cookies: string[] = [];

// Arc/AWS API Gateway will send back set-cookies outside of response headers.
for (let [key, values] of Object.entries(nodeResponse.headers.raw())) {
for (let [key, value] of nodeResponse.headers.entries()) {
if (key.toLowerCase() === "set-cookie") {
for (let value of values) {
cookies.push(value);
}
cookies.push(value);
}
}

Expand Down
4 changes: 3 additions & 1 deletion packages/remix-express/__tests__/server-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,9 @@ describe("express createRemixHeaders", () => {
describe("creates fetch headers from express headers", () => {
it("handles empty headers", () => {
let headers = createRemixHeaders({});
expect(headers.raw()).toMatchInlineSnapshot(`Object {}`);
expect(Object.fromEntries(headers.entries())).toMatchInlineSnapshot(
`Object {}`
);
});

it("handles simple headers", () => {
Expand Down
6 changes: 2 additions & 4 deletions packages/remix-express/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,8 @@ export async function sendRemixResponse(
res.statusMessage = nodeResponse.statusText;
res.status(nodeResponse.status);

for (let [key, values] of Object.entries(nodeResponse.headers.raw())) {
for (let value of values) {
res.append(key, value);
}
for (let [key, value] of nodeResponse.headers.entries()) {
res.append(key, value);
}

if (nodeResponse.body) {
Expand Down
2 changes: 1 addition & 1 deletion packages/remix-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
],
"dependencies": {
"@remix-run/server-runtime": "1.19.3",
"@remix-run/web-fetch": "^4.3.6",
"@remix-run/web-fetch": "^4.3.7",
"@remix-run/web-file": "^3.0.3",
"@remix-run/web-stream": "^1.0.4",
"@web3-storage/multipart-parser": "^1.0.0",
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2138,10 +2138,10 @@
"@remix-run/web-stream" "^1.0.4"
web-encoding "1.1.5"

"@remix-run/web-fetch@^4.3.6":
version "4.3.6"
resolved "https://registry.npmjs.org/@remix-run/web-fetch/-/web-fetch-4.3.6.tgz#7853f6496cfa2b9fb11298891b446062eab25738"
integrity sha512-ifadyJS+/7W6LhKyA8tIR9fBIPwLCFVpl1YCYg5i0ikykiXxE3IWtPVB1G51AJFghc1YgR7rq8BRJLsJeUbE5Q==
"@remix-run/web-fetch@^4.3.7":
version "4.3.7"
resolved "https://registry.npmjs.org/@remix-run/web-fetch/-/web-fetch-4.3.7.tgz#b391cd73bb5ecd8f4603e7151054712d9d5f0328"
integrity sha512-Ha6TuLiVHBbLuSNRgEQTz01pgG+bZVNogkKZt1cVi0asOuKISl0X2UgPLv+dWBqfcFvTi8CQvYUNuk5c89TcZw==
dependencies:
"@remix-run/web-blob" "^3.0.5"
"@remix-run/web-form-data" "^3.0.5"
Expand Down

0 comments on commit 0689d14

Please sign in to comment.