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",});proxy option can be a URL string or an object withurl and optionalheaders. The URL can include the username and password if the proxy requires authentication. It can behttp:// orhttps://.await fetch("https://example.com", { proxy: { url: "https://proxy.example.com:8080", headers: { "Proxy-Authorization": "Bearer my-token", "X-Proxy-Region": "us-east-1", }, },});headers property accepts a plain object or aHeaders instance. These headers are sent directly to the proxy server inCONNECT requests (for HTTPS targets) or in the proxy request (for HTTP targets).If you provide aProxy-Authorization header, it will override any credentials specified in the proxy URL.$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.tsWas this page helpful?