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 <noreply@anthropic.com>
This commit is contained in:
Corey Johnson 2026-03-10 17:31:19 -07:00
parent 89bf052ca1
commit 6774b456a9

View File

@ -29,10 +29,12 @@ function proxyFetch(req: Request): Promise<Response> | 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)