Skip to content
This repository was archived by the owner on Jan 28, 2025. It is now read-only.

Commit f0a9b86

Browse files
authored
perf(lambda-at-edge): do not decompress content from fetch in external rewrite (#871)
1 parent 42c9276 commit f0a9b86

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

packages/libs/lambda-at-edge/src/routing/rewriter.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@ const ignoredHeaders = [
6565
"content-length",
6666
"host",
6767
"transfer-encoding",
68-
"via",
69-
"content-encoding"
68+
"via"
7069
];
7170

7271
const ignoredHeaderPrefixes = ["x-amz-cf-", "x-amzn-", "x-edge-"];
@@ -107,12 +106,14 @@ export async function createExternalRewriteResponse(
107106
fetchResponse = await fetch(customRewrite, {
108107
headers: reqHeaders,
109108
method: req.method,
110-
body: decodedBody // Must pass body as a string
109+
body: decodedBody, // Must pass body as a string,
110+
compress: false
111111
});
112112
} else {
113113
fetchResponse = await fetch(customRewrite, {
114114
headers: reqHeaders,
115-
method: req.method
115+
method: req.method,
116+
compress: false
116117
});
117118
}
118119

@@ -122,6 +123,5 @@ export async function createExternalRewriteResponse(
122123
}
123124
}
124125
res.statusCode = fetchResponse.status;
125-
const text = await fetchResponse.text();
126-
res.end(text);
126+
res.end(await fetchResponse.buffer());
127127
}

0 commit comments

Comments
 (0)