From c223f8fd65804723f27bf3efb986c11b30e0cfb5 Mon Sep 17 00:00:00 2001 From: Samuel Macleod Date: Fri, 10 Jan 2025 21:03:38 +0000 Subject: [PATCH] Fix tests --- .../edge-preview-authenticated-proxy/src/index.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/packages/edge-preview-authenticated-proxy/src/index.ts b/packages/edge-preview-authenticated-proxy/src/index.ts index 1e0241add9a4..5f76a5412439 100644 --- a/packages/edge-preview-authenticated-proxy/src/index.ts +++ b/packages/edge-preview-authenticated-proxy/src/index.ts @@ -250,6 +250,20 @@ async function handleRawHttp(request: Request, url: URL) { Vary: "Origin", }); + // Pass the raw content type back so that clients can decode the body correctly + const contentType = responseHeaders.get("Content-Type"); + if (contentType) { + rawHeaders.set("Content-Type", contentType); + } + const contentEncoding = responseHeaders.get("Content-Encoding"); + if (contentEncoding) { + rawHeaders.set("Content-Encoding", contentEncoding); + } + const transferEncoding = responseHeaders.get("Transfer-Encoding"); + if (transferEncoding) { + rawHeaders.set("Transfer-Encoding", transferEncoding); + } + // The client needs the raw headers from the worker // Prefix them with `cf-ew-raw-`, so that response headers from _this_ worker don't interfere const setCookieHeader = responseHeaders.getSetCookie();