Skip to content

[Bug]: Node-side fetch ignores proxy env vars and fails on proxy-required sites #510

@WSL0809

Description

@WSL0809

Description

opencli does not honor http_proxy / https_proxy for Node-side fetch requests, so commands that require the configured proxy fail with TypeError: fetch failed even though the same URLs work with curl in the same environment.

Steps to Reproduce

Steps to reproduce

  1. Run export http_proxy=http://127.0.0.1:7897 && export https_proxy=http://127.0.0.1:7897
  2. Run opencli v2ex latest -f json
  3. See error

Actual behavior

opencli fails with a Node fetch error on sites that require the configured proxy:

TypeError: fetch failed
at node:internal/deps/undici/undici:15482:13
...
[cause]: AggregateError [ETIMEDOUT]

In my case, opencli v2ex hot --verbose also failed earlier with the same Node-side fetch failed stack.

Expected behavior

opencli should honor http_proxy / https_proxy automatically, the same way curl does, and successfully return V2EX results.

Environment

Additional context

This does not affect every command. For example, opencli apple-podcasts top works fine in the same shell, which suggests the bug only shows up for endpoints that need the configured proxy to be reachable.

Also, plain curl to V2EX works in the same environment, so the issue seems specific to Node-side fetch not using the proxy env vars by default.

Workaround

Running with NODE_USE_ENV_PROXY=1 makes the same request succeed:

NODE_USE_ENV_PROXY=1 opencli v2ex latest -f json

Expected Behavior

opencli should automatically use the configured proxy environment variables for Node-side network requests and return command results successfully instead of timing out with fetch failed.

OpenCLI Version

1.5.0

Node.js Version

Other

Operating System

macOS

Logs / Screenshots

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions