Description
When HTTP_PROXY or HTTPS_PROXY is set, opencode attach http://127.0.0.1:<port> routes its requests (e.g. GET /config/providers) through the proxy even when NO_PROXY includes 127.0.0.1/localhost. This breaks attaching to a local server when a corporate/system proxy is configured.
The attach path connects via createOpencodeClient, which falls back to the runtime's global fetch (packages/sdk/js/src/v2/client.ts:51-56) with no proxy handling. Bun's native fetch honors HTTP(S)_PROXY but not NO_PROXY. The repo already ships a correct NO_PROXY-aware resolver (packages/opencode/src/util/proxy-env.ts, getProxyForUrl/shouldProxy), but it's only wired into the OpenAI WebSocket path (packages/opencode/src/plugin/openai/ws.ts:88) — whose own comment notes "Bun does not apply HTTP(S)_PROXY to WebSockets unless the proxy is supplied explicitly." The HTTP/attach path has no equivalent, and unlike the desktop app (packages/desktop/src/main/sidecar.ts ensureLoopbackNoProxy()) it does no loopback bypass.
Steps to reproduce
export HTTPS_PROXY=http://your-proxy:8080 (and/or HTTP_PROXY)
export NO_PROXY=127.0.0.1,localhost
- Start an opencode server, then
opencode attach http://127.0.0.1:<port>
- The request to
127.0.0.1 still goes through the proxy instead of connecting directly.
OpenCode version
1.18.0 (Bun 1.3.14)
Operating System
Linux (WSL2)
Description
When
HTTP_PROXYorHTTPS_PROXYis set,opencode attach http://127.0.0.1:<port>routes its requests (e.g.GET /config/providers) through the proxy even whenNO_PROXYincludes127.0.0.1/localhost. This breaks attaching to a local server when a corporate/system proxy is configured.The attach path connects via
createOpencodeClient, which falls back to the runtime's globalfetch(packages/sdk/js/src/v2/client.ts:51-56) with no proxy handling. Bun's native fetch honorsHTTP(S)_PROXYbut notNO_PROXY. The repo already ships a correctNO_PROXY-aware resolver (packages/opencode/src/util/proxy-env.ts,getProxyForUrl/shouldProxy), but it's only wired into the OpenAI WebSocket path (packages/opencode/src/plugin/openai/ws.ts:88) — whose own comment notes "Bun does not apply HTTP(S)_PROXY to WebSockets unless the proxy is supplied explicitly." The HTTP/attach path has no equivalent, and unlike the desktop app (packages/desktop/src/main/sidecar.tsensureLoopbackNoProxy()) it does no loopback bypass.Steps to reproduce
export HTTPS_PROXY=http://your-proxy:8080(and/orHTTP_PROXY)export NO_PROXY=127.0.0.1,localhostopencode attach http://127.0.0.1:<port>127.0.0.1still goes through the proxy instead of connecting directly.OpenCode version
1.18.0 (Bun 1.3.14)
Operating System
Linux (WSL2)