Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/slimy-squids-juggle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@opennextjs/aws": patch
---

fix: Handle location header array with a single value without emitting warning
2 changes: 1 addition & 1 deletion packages/open-next/src/http/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
16 changes: 16 additions & 0 deletions packages/tests-unit/tests/http/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
});
});
});
Loading