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 <noreply@anthropic.com>
This commit is contained in:
Corey Johnson 2026-03-10 18:57:19 -07:00
parent a344e293f1
commit e197a6d3bb

View File

@ -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 })