proxy fixes

This commit is contained in:
Chris Wanstrath 2026-02-16 09:34:19 -08:00
parent caac6877d7
commit 1dc7b76b31

View File

@ -38,12 +38,20 @@ export async function proxySubdomain(subdomain: string, req: Request): Promise<R
const url = new URL(req.url) const url = new URL(req.url)
const target = `http://localhost:${app.port}${url.pathname}${url.search}` const target = `http://localhost:${app.port}${url.pathname}${url.search}`
const hasBody = req.method !== 'GET' && req.method !== 'HEAD'
const body = hasBody ? await req.arrayBuffer() : undefined
const headers = new Headers(req.headers)
headers.delete('host')
headers.delete('connection')
headers.delete('keep-alive')
headers.delete('transfer-encoding')
try { try {
return await fetch(target, { return await fetch(target, {
method: req.method, method: req.method,
headers: req.headers, headers,
body: req.method !== 'GET' && req.method !== 'HEAD' ? req.body : undefined, body,
}) })
} catch (e) { } catch (e) {
console.error(`Proxy error for ${subdomain}:`, e) console.error(`Proxy error for ${subdomain}:`, e)