property
BunFetchRequestInit.proxy
proxy?: string | URL | { headers: HeadersInit; url: string | URL }
The proxy to send the request through, overriding the http_proxy and HTTPS_PROXY environment variables. Accepts a URL string, a URL instance, or an object with url and optional headers.
If a Proxy-Authorization header is provided in proxy.headers, it takes precedence over credentials parsed from the proxy URL.
Not part of the Fetch API specification.
// String format
const response = await fetch("http://example.com", {
proxy: "https://username:password@127.0.0.1:8080"
});
// Object format with custom headers sent to the proxy
const response = await fetch("http://example.com", {
proxy: {
url: "https://127.0.0.1:8080",
headers: {
"Proxy-Authorization": "Bearer token",
"X-Custom-Proxy-Header": "value"
}
}
});