Skip to content

Commit ab980f0

Browse files
committed
avoid creating unnecessary headers instance
1 parent d07c9f1 commit ab980f0

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

.changeset/red-kiwis-press.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@opennextjs/aws": patch
3+
---
4+
5+
Avoid creating unnecessary headers instance on every request

packages/open-next/src/overrides/wrappers/cloudflare-node.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,12 @@ const handler: WrapperHandler<InternalEvent, InternalResult> =
4141
}): Writable {
4242
const { statusCode, cookies, headers } = prelude;
4343

44-
const responseHeaders = new Headers(headers);
45-
for (const cookie of cookies) {
46-
responseHeaders.append("Set-Cookie", cookie);
47-
}
44+
headers["set-cookie"] = cookies.join(",");
4845

4946
// TODO(vicb): this is a workaround to make PPR work with `wrangler dev`
5047
// See https://github.com/cloudflare/workers-sdk/issues/8004
5148
if (url.hostname === "localhost") {
52-
responseHeaders.set("Content-Encoding", "identity");
49+
headers["content-encoding"] = "identity";
5350
}
5451

5552
const { readable, writable } = new TransformStream({
@@ -60,7 +57,7 @@ const handler: WrapperHandler<InternalEvent, InternalResult> =
6057
const body = NULL_BODY_STATUSES.has(statusCode) ? null : readable;
6158
const response = new Response(body, {
6259
status: statusCode,
63-
headers: responseHeaders,
60+
headers,
6461
});
6562
resolveResponse(response);
6663

0 commit comments

Comments
 (0)