proxy fixes
This commit is contained in:
parent
caac6877d7
commit
1dc7b76b31
|
|
@ -38,12 +38,20 @@ export async function proxySubdomain(subdomain: string, req: Request): Promise<R
|
|||
|
||||
const url = new URL(req.url)
|
||||
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 {
|
||||
return await fetch(target, {
|
||||
method: req.method,
|
||||
headers: req.headers,
|
||||
body: req.method !== 'GET' && req.method !== 'HEAD' ? req.body : undefined,
|
||||
headers,
|
||||
body,
|
||||
})
|
||||
} catch (e) {
|
||||
console.error(`Proxy error for ${subdomain}:`, e)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user