fix(proxy-pools): lossless header forwarding for relay pools

Preserve request headers through the Vercel/Cloudflare/Deno relay.

- proxyFetch: normalize options.headers via Object.fromEntries before
  spreading into the relay headers. Spreading a Headers instance yields
  {} and silently dropped every entry (auth + content-type), which is why
  the same pool worked on one path and failed on another.
- vercel relay: build the forwarded header object from req.headers.entries()
  instead of new Headers(req.headers), avoiding edge-runtime normalization
  of casing/duplicate keys that some providers reject.
This commit is contained in:
savioruz
2026-09-23 09:11:50 +07:00
committed by decolua
parent cbffeb9770
commit 6af26a9ee8
2 changed files with 10 additions and 6 deletions

View File

@@ -298,8 +298,11 @@ export async function proxyAwareFetch(url, options = {}, proxyOptions = null) {
const vercelRelayUrl = normalizeString(proxyOptions?.vercelRelayUrl);
if (vercelRelayUrl) {
const parsed = new URL(targetUrl);
const baseHeaders = options.headers instanceof Headers
? Object.fromEntries(options.headers.entries())
: { ...(options.headers || {}) };
const relayHeaders = {
...options.headers,
...baseHeaders,
"x-relay-target": `${parsed.protocol}//${parsed.host}`,
"x-relay-path": `${parsed.pathname}${parsed.search}`,
};