Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 31, 2026

ofetch works on Node.js, Bun, and Deno, but only Node.js proxy configuration was documented. This PR adds concise proxy documentation for all three runtimes.

Changes

README.md

  • Added important callout at the top about environment variable support:
    • Bun and Deno respect HTTP_PROXY and HTTPS_PROXY environment variables
    • Node.js requires NODE_USE_ENV_PROXY=1 to enable built-in proxy support
  • Reorganized "Adding HTTP(S) Agent" → "Proxy Support" with compact, runtime-specific subsections
  • Node.js: Streamlined documentation for undici ProxyAgent with dispatcher option (basic proxy, global proxy, self-signed certs)
  • Bun and Deno: Combined subsection documenting:
    • Bun's native proxy option: proxy: "http://localhost:3128"
    • Deno's undici npm specifier option for programmatic configuration

examples/proxy.mjs

  • Unified example showing all three proxy configuration approaches in one file (~18 lines)
  • Single ofetch call with all three proxy options shown with clear comments
  • All options commented out by default - users uncomment the relevant import and option for their runtime

Example

The unified example in examples/proxy.mjs:

import { ofetch } from "ofetch";

// Node.js: Use undici ProxyAgent with dispatcher option
// import { ProxyAgent } from "undici";
// const proxyAgent = new ProxyAgent("http://localhost:3128");

// Bun: Use native proxy option
// const proxy = "http://localhost:3128";

// Deno: Set HTTP_PROXY environment variable or use undici with npm specifier
// HTTP_PROXY=http://localhost:3128 deno run --allow-net proxy.mjs

const data = await ofetch("https://icanhazip.com", {
  // dispatcher: proxyAgent, // Node.js
  // proxy, // Bun
});

console.log(data);

The documentation is compact (~45 lines in README vs original ~130 lines) and the example is unified (~18 lines vs original ~65 lines) while maintaining all essential information.

Original prompt

This section details on the original issue you should resolve

<issue_title>Bun proxy support</issue_title>
<issue_description>### Describe the feature

Currently, ofetch proxy support use the node undici features.
Bun has a different way to use proxy (through the proxy option) instead of agents.

I may be able to implement this later as I guess it's not a urgent issue.

Additional information

  • Would you be willing to help implement this feature?</issue_description>

<agent_instructions>research in Bun and Deno docs how to programatically set proxy per fetch. Add short readme docs about proxy for Node, Deno and Bun updating old section</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@pi0 Hi. Types might be missing but you can pass any config to fetch options, incliding bun specific proxy config. @pi0 We should def add a note in docs about using proxy with Deno and Bun, PR welcome!

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Add Bun proxy support for fetch Document proxy configuration for Bun and Deno Jan 31, 2026
Copilot AI requested a review from pi0 January 31, 2026 10:21
@pi0
Copy link
Member

pi0 commented Jan 31, 2026

@copilot

  • update title to be semantic
  • move bun and deno below node section also make docs more compact, simple

Copy link
Contributor Author

Copilot AI commented Jan 31, 2026

@copilot

  • update title to be semantic
    ...

Made the documentation more compact and simple in f39d26d. The section now has:

  • Node.js first with 3 focused examples (basic proxy, global proxy, self-signed certs)
  • Bun and Deno combined in one subsection below
  • Removed verbose explanations and duplicate examples
  • Reduced from ~130 lines to ~40 lines while keeping all essential information

Regarding the semantic title - I can't update the PR title directly, but suggest: "docs: add proxy configuration for Bun and Deno"

Copilot AI changed the title Document proxy configuration for Bun and Deno docs: add proxy configuration for Bun and Deno Jan 31, 2026
README.md Outdated
});
```

**Deno** and Bun respect `HTTP_PROXY` and `HTTPS_PROXY` environment variables. Deno can also use undici with npm specifiers for programmatic configuration.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot Move this note to first of proxy support section as an > [IMPORTANT] bot and mention Node.js needs NODE_USE_ENV_PROXY-1 for global env var (https://nodejs.org/api/http.html#http_built_in_proxy_support)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the important callout about environment variables at the top of the proxy support section in 94bc5c6. The note now mentions that Node.js requires NODE_USE_ENV_PROXY=1 to enable built-in proxy support, with a link to the Node.js documentation.

Copilot AI requested a review from pi0 February 4, 2026 10:20
Copy link
Contributor Author

Copilot AI commented Feb 4, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • icanhazip.com
    • Triggering command: /usr/local/bin/node node examples/proxy.mjs (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@pi0 pi0 marked this pull request as ready for review February 4, 2026 10:26
@pi0 pi0 merged commit d50a204 into main Feb 4, 2026
4 checks passed
@pi0 pi0 deleted the copilot/add-bun-proxy-support branch February 4, 2026 10:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bun proxy support

2 participants