From 21d2553c35d0ef2db3f7a3afaabf5d6b0f2aef94 Mon Sep 17 00:00:00 2001 From: Donna Belsey <5080993+donnabelsey@users.noreply.github.com> Date: Wed, 15 Oct 2025 15:38:54 +0100 Subject: [PATCH 1/2] fix: Handle location header array with a single value without emitting warning Co-authored with @brunns Related to #977 --- packages/open-next/src/http/util.ts | 2 +- packages/tests-unit/tests/http/utils.test.ts | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/packages/open-next/src/http/util.ts b/packages/open-next/src/http/util.ts index de3b07de6..19f479b97 100644 --- a/packages/open-next/src/http/util.ts +++ b/packages/open-next/src/http/util.ts @@ -23,7 +23,7 @@ export const parseHeaders = ( * and https://github.com/opennextjs/opennextjs-aws/pull/977#issuecomment-3261763114 */ if (keyLower === "location" && Array.isArray(value)) { - if (value[0] === value[1]) { + if (value.length === 1 || value[0] === value[1]) { result[keyLower] = value[0]; } else { logger.warn( diff --git a/packages/tests-unit/tests/http/utils.test.ts b/packages/tests-unit/tests/http/utils.test.ts index 34f0717dc..79670c555 100644 --- a/packages/tests-unit/tests/http/utils.test.ts +++ b/packages/tests-unit/tests/http/utils.test.ts @@ -65,4 +65,20 @@ describe("parseHeaders", () => { "x-opennext": "is-so-cool", }); }); + + it("handles location header array with a single value", () => { + const headers = parseHeaders({ + location: ["/target"], + "x-custom-header": "customValue", + "x-multiple-values": ["value1", "value2"], + "x-undefined-header": undefined, + "x-opennext": "is-so-cool", + } as unknown as http.OutgoingHttpHeaders); + expect(headers).toEqual({ + location: "/target", + "x-custom-header": "customValue", + "x-multiple-values": "value1,value2", + "x-opennext": "is-so-cool", + }); + }); }); From c8959c0f9e6e02d7f2707b510ecee67f3068400a Mon Sep 17 00:00:00 2001 From: Donna Belsey <5080993+donnabelsey@users.noreply.github.com> Date: Wed, 15 Oct 2025 16:00:52 +0100 Subject: [PATCH 2/2] Add changeset Co-authored with @brunns --- .changeset/slimy-squids-juggle.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/slimy-squids-juggle.md diff --git a/.changeset/slimy-squids-juggle.md b/.changeset/slimy-squids-juggle.md new file mode 100644 index 000000000..b610db5cb --- /dev/null +++ b/.changeset/slimy-squids-juggle.md @@ -0,0 +1,5 @@ +--- +"@opennextjs/aws": patch +--- + +fix: Handle location header array with a single value without emitting warning