From e197a6d3bb59082b599b8d8232a9b88f43982bc4 Mon Sep 17 00:00:00 2001 From: Corey Johnson Date: Tue, 10 Mar 2026 18:57:19 -0700 Subject: [PATCH] Use decompress: false for transparent proxy passthrough Bun's fetch has a decompress option that passes responses through without interpreting content-encoding. This replaces all the manual header stripping workarounds. Co-Authored-By: Claude Opus 4.6 --- src/proxy.ts | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/proxy.ts b/src/proxy.ts index b282a9f..8c5f59b 100644 --- a/src/proxy.ts +++ b/src/proxy.ts @@ -19,20 +19,14 @@ export function createProxy(socketPath: string, isHealthy: () => boolean, isRunn } const hasBody = req.method !== 'GET' && req.method !== 'HEAD' - const headers = new Headers(req.headers) - headers.delete('accept-encoding') const body = hasBody ? await req.arrayBuffer() : undefined return fetch(`http://localhost${url.pathname}${url.search}`, { method: req.method, - headers, + headers: req.headers, body, unix: socketPath, - }).then((r) => { - const respHeaders = new Headers(r.headers) - respHeaders.delete('content-encoding') - respHeaders.delete('content-length') - return new Response(r.body, { status: r.status, headers: respHeaders }) + decompress: false, }).catch((e) => { console.error('Proxy error:', e) return new Response('Tronbyt server is not responding', { status: 502 })