From 6774b456a97fd97cb8a2145c0aaeb72cbe8d2cff Mon Sep 17 00:00:00 2001 From: Corey Johnson Date: Tue, 10 Mar 2026 17:31:19 -0700 Subject: [PATCH] Don't forward body for GET/HEAD requests in proxy Passing req.body (a ReadableStream) for GET requests could cause the unix socket fetch to hang waiting for body data, especially when the upstream toes proxy has already stripped content-length. Co-Authored-By: Claude Opus 4.6 --- src/server.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/server.ts b/src/server.ts index d658ec8..9cbb65d 100644 --- a/src/server.ts +++ b/src/server.ts @@ -29,10 +29,12 @@ function proxyFetch(req: Request): Promise | Response { .catch(() => new Response('unhealthy', { status: 503 })) } + const hasBody = req.method !== 'GET' && req.method !== 'HEAD' + return fetch(`http://localhost${url.pathname}${url.search}`, { method: req.method, headers: req.headers, - body: req.body, + body: hasBody ? req.body : undefined, unix: SOCKET_PATH, }).catch((e) => { console.error('Proxy error:', e)