skills/bun-guides-http-proxy/SKILL.md
Proxy HTTP requests using fetch()
npx skillsauth add jarle/bun-skills Bun Proxy HTTP requests using fetch()Install this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
In Bun, fetch supports sending requests through an HTTP or HTTPS proxy. This is useful on corporate networks or when you need to ensure a request is sent through a specific IP address.
await fetch("https://example.com", {
// The URL of the proxy server
proxy: "https://username:[email protected]:8080",
});
The proxy option can be a URL string or an object with url and optional headers. The URL can include the username and password if the proxy requires authentication. It can be http:// or https://.
To send custom headers to the proxy server (useful for proxy authentication tokens, custom routing, etc.), use the object format:
await fetch("https://example.com", {
proxy: {
url: "https://proxy.example.com:8080",
headers: {
"Proxy-Authorization": "Bearer my-token",
"X-Proxy-Region": "us-east-1",
},
},
});
The headers property accepts a plain object or a Headers instance. These headers are sent directly to the proxy server in CONNECT requests (for HTTPS targets) or in the proxy request (for HTTP targets).
If you provide a Proxy-Authorization header, it will override any credentials specified in the proxy URL.
You can also set the $HTTP_PROXY or $HTTPS_PROXY environment variable to the proxy URL. This is useful when you want to use the same proxy for all requests.
HTTPS_PROXY=https://username:[email protected]:8080 bun run index.ts
development
Using TypeScript with Bun, including type definitions and compiler options
development
Learn how to write tests using Bun's Jest-compatible API with support for async tests, timeouts, and various test modifiers
testing
Learn how to use snapshot testing in Bun to save and compare output between test runs
testing
Learn about Bun test's runtime integration, environment variables, timeouts, and error handling