Skip to content

Support HTTP_PROXY/HTTPS_PROXY/NO_PROXY #2917

@mhio

Description

@mhio

Please avoid duplicates

Context

Node now supports HTTP_PROXY/HTTPS_PROXY/NO_PROXY natively via NODE_USE_ENV_PROXY=1 and --use-env-proxy PR nodejs/node#58980

There's three modes I can immediately think of that might be needed globally or per test.

  • Use ENV config based on Node options
  • Support any ENV config, ensure nock works with any test proxy config
  • Ignore any proxy ENV settings and respond to plain request/response meta

From two perspectives

  • App's that use proxies and want to test them.
  • Test environments that have proxies but don't want to test them (or want test them all the time).

There's probably some interplay with how much fetch can be configured after the --use-env-proxy argument as to what nock could need to support.

Related issues:
#2089
#2114

As @arunprakashadithyan showed a proxy can currently be worked around by a nock on the proxy server and ignoring the real http host in the path:

nock('http://149.129.239.170:8002', {allowUnmocked: true}).persist()
  .get(resource => resource.includes('/comments'))

Alternatives

No response

If the feature request is accepted, would you be willing to submit a PR?

  • yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions