Skip to content

feat(network): honor HTTPS_PROXY, HTTP_PROXY and NO_PROXY - #51

Merged
AltaMills merged 6 commits into
mainfrom
ark/env-proxy
Nov 9, 2026
Merged

AltaMills merged 6 commits into
mainfrom
ark/env-proxy

Conversation

@AltaMills

@AltaMills AltaMills commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Node's fetch ignores HTTPS_PROXY / HTTP_PROXY / NO_PROXY unless Node itself was started with NODE_USE_ENV_PROXY=1 (Node 22.21+, 24+). Cursor's sandbox allows the network only through a proxy it names in those variables, so every meshy-cli command there failed at its first request (oauth_network). The Meshy plugin works around it by starting the CLI with NODE_USE_ENV_PROXY=1 (meshy-dev/meshy-3d-agent#27), which needs a newer Node than the CLI requires (22.12+).

With this change the CLI honors the variables itself:

  • At start (src/index.ts), before any request, useProxyFromEnv() (src/internal/proxy.ts) reads https_proxy / HTTPS_PROXY, http_proxy / HTTP_PROXY and no_proxy / NO_PROXY, lowercase first as curl and undici do.
  • When either proxy is set, it installs undici's EnvHttpProxyAgent as the global dispatcher once. Every fetch then goes through the proxy: the API, sign-in, downloads, input URL checks, and the update check's child, which starts through the same entry point.
    • https: URLs use HTTPS_PROXY (a CONNECT tunnel) and fall back to HTTP_PROXY. http: URLs go to the proxy as plain forwarded requests (proxyTunnel: false), as curl sends them.
    • Hosts in NO_PROXY go direct (passed as given, so * still means all), and so does this machine (localhost, 127.0.0.0/8, ::1) always, as Go's net/http does, so a local API's credential never crosses the proxy in the clear. NO_PROXY cannot express a range, so a thin dispatcher in front sends loopback hosts to a plain agent and everything else to EnvHttpProxyAgent.
    • An https:// proxy tunnels http: URLs too: undici forwards plain HTTP only through an http:// proxy and has no switch for it. Documented in docs/usage.md and D-093.
  • A proxy value undici cannot use does not fall back to going direct: not http:// or https://, no host, a query, a bad escape. The check builds the ProxyAgent undici would build, so nothing undici accepts is refused. Every request fails before it leaves, with an error that names the variable and never its value (it may hold a password). Local commands still run. Sign-in, downloads and input URL checks report the same message, and sign-in points at the proxy variables.
  • A request the proxy refuses (a CONNECT not answered 200, a forwarded request answered 407), or whose TLS handshake with an https:// proxy fails (UND_ERR_PRX_TLS), never reached Meshy. proxyFailure() recognizes undici's errors for these, and the transport classifies them as connect, so a task create is recorded not_submitted rather than unknown. The error says it was the proxy.
  • Without a proxy variable nothing changes.
  • undici is a new dependency for this alone, and it loads only when a proxy variable is set (src/internal/proxy-dispatcher.ts, dynamically imported). Loading it at every start cost about 40 ms: --version takes 106 ms without a proxy variable, against 157 ms when it was imported up front. Node's own http.setGlobalProxyFromEnv exists in 24.20 but not in Node 22. The global dispatcher is what Node's built-in fetch uses on both, so one code path covers every supported Node. Verified on Node 22.23 (bundled undici 6.29) and 24.20 (bundled undici 7.29).
  • The transport's rules are unchanged: no redirects followed, no URL outside its base. For https: URLs the proxy sees only a CONNECT tunnel.
  • Docs: the --help environment list, docs/usage.md, and decision D-093 in docs/decisions.md.

Once a release with this is out, the plugin can drop NODE_USE_ENV_PROXY=1 and the Node version it needs.

Tests

tests/proxy.test.ts, with a loopback forward proxy that counts what it carries. Targets that must go through it use a .invalid host, which never resolves, so a request that reaches the target went through the proxy:

  • no proxy variable: nothing installed;
  • both spellings read, lowercase first; unset values passed as "", so undici does not read process.env again; NO_PROXY passed as given;
  • an invalid proxy URL: the variable is named, the password never appears, the request is never sent, and nothing goes direct;
  • a proxy that refuses CONNECT still forwards an http: request;
  • NO_PROXY (including *), localhost, 127.0.0.1 and [::1] go direct, and isLoopbackHost covers 127.0.0.0/8 and IPv4-mapped forms;
  • a refused CONNECT (https) and a forwarded 407 (http) are both neverSent, with an error naming the proxy;
  • a failed TLS handshake with an https:// proxy (undici's UND_ERR_PRX_TLS, built as fetch delivers it) is neverSent too;
  • end to end: the built CLI's balance request goes through HTTP_PROXY, and an API on loopback is reached directly.

Runs:

  • pnpm test on Node 24.20: 705 tests, 704 pass, 1 skipped, 0 fail (see the latest commit).
  • tests/proxy.test.ts on Node 22.23 and 24.20: 9/9 pass.
  • Mutations, each failing its test: removing the useProxyFromEnv() call; tunneling http: again; looking only one cause deep for the refusal; letting an invalid URL go direct; skipping the ProxyAgent check; loopback as 127.0.0.1 only; dropping the loopback dispatcher; appending to NO_PROXY again; the old sign-in hint; not recognizing UND_ERR_PRX_TLS.

Not covered in the suite: an https: request completed through a CONNECT tunnel to a TLS target (no TLS target in the suite). The review checked it separately on Node 22.12.0, including a certificate-name mismatch still failing.

🤖 Generated with Claude Code

AltaMills and others added 6 commits November 9, 2026 17:28
Node's fetch ignores the proxy variables unless Node was started with
NODE_USE_ENV_PROXY=1 (22.21+, 24+). Cursor's sandbox allows the network
only through the proxy it names in them, so every command there failed at
its first request, and the Meshy plugin had to start the CLI with
NODE_USE_ENV_PROXY=1.

At start, when HTTPS_PROXY or HTTP_PROXY is set (lowercase spellings too),
install undici's EnvHttpProxyAgent as the global dispatcher, so every fetch
goes through the proxy unless NO_PROXY exempts its host, on every Node the
CLI supports. Without the variables nothing changes (D-093).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…n a bad proxy URL

- http: URLs go to the proxy as plain forwarded requests (proxyTunnel:
  false), as curl sends them; https: still tunnels. A proxy that refuses
  CONNECT but forwards HTTP works.
- localhost, 127.0.0.1 and [::1] always go direct, as Go's net/http does,
  so a local API's credential never crosses the proxy.
- A proxy value that is not an http(s) URL no longer throws at start with
  the value (and any password) in the stack: every request fails before it
  leaves, naming the variable only. Local commands still run.
- A proxy that refuses the request (CONNECT not 200, forwarded 407) is a
  request never sent: the transport classifies it as connect, so a task is
  recorded not_submitted rather than unknown, and the error says so.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…a proxy is set

- This machine (localhost, 127.0.0.0/8, ::1) goes direct through a thin
  dispatcher in front of EnvHttpProxyAgent, instead of entries appended to
  NO_PROXY, which broke NO_PROXY=* and could not express the range.
- A proxy URL is checked by building the ProxyAgent undici would build, so
  values that parse as URLs but that undici rejects (a bad escape, a query)
  fail closed with the variable named instead of throwing at start.
- Sign-in, downloads and input URL checks report a proxy failure the same
  way, and sign-in points at the proxy variables.
- undici loads only when a proxy variable is set (proxy-dispatcher.ts, a
  dynamic import): it cost every command about 40 ms at start.
- Docs: an https:// proxy tunnels http: URLs too (undici has no switch).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…est never sent

undici wraps a certificate-name mismatch with an https:// proxy as
SecureProxyConnectionError (UND_ERR_PRX_TLS), which the transport did not
count as a connect failure, so a create that never left was recorded with
an unknown outcome. proxyFailure() now recognizes it, and the message says
the TLS connection to the proxy failed. Other certificate and connection
errors with the proxy already arrive as their own errno.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@AltaMills
AltaMills merged commit 57ab594 into main Nov 9, 2026
7 checks passed
AltaMills added a commit that referenced this pull request Nov 9, 2026
Version 0.8.5 for the release: requests honor `HTTPS_PROXY`,
`HTTP_PROXY` and `NO_PROXY` on every supported Node (D-093, #51).
Cursor's sandbox allows the network only through such a proxy; with this
release the Meshy plugin no longer needs `NODE_USE_ENV_PROXY=1`.

Checked locally on this branch:

- `pnpm typecheck`
- `pnpm test`: 705 tests, 704 pass, 0 fail, 1 skipped (already skipped
before)
- `pnpm build`
- `node dist/index.js --version` prints 0.8.5

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
AltaMills added a commit to meshy-dev/meshy-3d-agent that referenced this pull request Nov 9, 2026
0.8.5 (meshy-dev/meshy-cli#51) honors HTTPS_PROXY / HTTP_PROXY /
NO_PROXY on every supported Node, so the CLI works inside Cursor's
sandbox without NODE_USE_ENV_PROXY=1. It includes 0.8.4's agent segment
in the User-Agent. Raise the minimum and the temporary package from 0.8.4
to 0.8.5; the release stays 0.9.5.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
serafin-meshy pushed a commit to meshy-dev/meshy-3d-agent that referenced this pull request Nov 9, 2026
…t (0.9.5) (#28)

* [PRO-4051] require Meshy CLI 0.8.4, which names the AI agent (0.9.5)

Meshy CLI 0.8.4 names the AI agent running a command (Cursor, Claude Code,
Codex, ...) in the User-Agent of its requests to Meshy, and meshyd now
records it (taichi-dev/meshyd#8127). The skills only upgrade a CLI older
than their minimum, so a machine with 0.8.3 would never send it: raise the
minimum and the temporary package to 0.8.4, and release 0.9.5.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* [PRO-4051] require Meshy CLI 0.8.5: agent attribution and proxy support

0.8.5 (meshy-dev/meshy-cli#51) honors HTTPS_PROXY / HTTP_PROXY /
NO_PROXY on every supported Node, so the CLI works inside Cursor's
sandbox without NODE_USE_ENV_PROXY=1. It includes 0.8.4's agent segment
in the User-Agent. Raise the minimum and the temporary package from 0.8.4
to 0.8.5; the release stays 0.9.5.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant