diff --git a/sidecar/index.ts b/sidecar/index.ts index 9d09ecf..f257a5f 100644 --- a/sidecar/index.ts +++ b/sidecar/index.ts @@ -307,7 +307,12 @@ const server = Bun.serve({ // `appSubUrl`, patched below by the same pass, is what makes Gitea's own scripts correct. if ((out.get('content-type') ?? '').includes('text/html')) { const body = rewriteHtml(await upstream.text(), base, origins); + // BOTH of these, and the second is not optional. `.text()` has already decompressed, so the + // body being returned is plain — while `out` still carries Gitea's `content-encoding: gzip`. + // The next hop believes that header, tries to gunzip plain text, and fails with ZlibError: + // a 502 that names nothing and looks exactly like the sidecar being unreachable. out.delete('content-length'); // the body just changed length + out.delete('content-encoding'); // and is no longer compressed return new Response(body, { status: upstream.status, headers: out }); } }