From 465a5c9b96907b14a49990ad80b8122f9fa2e848 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Wed, 16 Aug 2023 22:35:07 +0200 Subject: [PATCH] fix: use `headers.entries()` instead of `headers.raw()` (#7150) --- .changeset/orange-suits-nail.md | 7 +++++++ packages/remix-architect/__tests__/server-test.ts | 4 +++- packages/remix-architect/server.ts | 6 ++---- packages/remix-express/__tests__/server-test.ts | 4 +++- packages/remix-express/server.ts | 6 ++---- packages/remix-node/package.json | 2 +- yarn.lock | 8 ++++---- 7 files changed, 22 insertions(+), 15 deletions(-) create mode 100644 .changeset/orange-suits-nail.md diff --git a/.changeset/orange-suits-nail.md b/.changeset/orange-suits-nail.md new file mode 100644 index 00000000000..9fe5caad30b --- /dev/null +++ b/.changeset/orange-suits-nail.md @@ -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/web-fetch@4.3.7` diff --git a/packages/remix-architect/__tests__/server-test.ts b/packages/remix-architect/__tests__/server-test.ts index 5c27d2748ba..f32c07aac49 100644 --- a/packages/remix-architect/__tests__/server-test.ts +++ b/packages/remix-architect/__tests__/server-test.ts @@ -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", () => { diff --git a/packages/remix-architect/server.ts b/packages/remix-architect/server.ts index f90e89c336a..81340c9cc9b 100644 --- a/packages/remix-architect/server.ts +++ b/packages/remix-architect/server.ts @@ -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); } } diff --git a/packages/remix-express/__tests__/server-test.ts b/packages/remix-express/__tests__/server-test.ts index adc45c4adc6..75f9e835671 100644 --- a/packages/remix-express/__tests__/server-test.ts +++ b/packages/remix-express/__tests__/server-test.ts @@ -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", () => { diff --git a/packages/remix-express/server.ts b/packages/remix-express/server.ts index a775a006fe9..a3f14ce0d54 100644 --- a/packages/remix-express/server.ts +++ b/packages/remix-express/server.ts @@ -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) { diff --git a/packages/remix-node/package.json b/packages/remix-node/package.json index 4ccb959c1e1..def114e1083 100644 --- a/packages/remix-node/package.json +++ b/packages/remix-node/package.json @@ -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", diff --git a/yarn.lock b/yarn.lock index eaee585b4be..12fcff44a04 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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"