Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nock does not match request when proxy environment variable is set #2114

Closed
berlund opened this issue Nov 17, 2020 · 2 comments
Closed

Nock does not match request when proxy environment variable is set #2114

berlund opened this issue Nov 17, 2020 · 2 comments

Comments

@berlund
Copy link

berlund commented Nov 17, 2020

What is the expected behavior?
Nock should match a request independent from an existing proxy configuration.

What is the actual behavior?
When HTTP_PROXY or HTTPS_PROXY is set, the incoming url consists of the proxy and the actual url, resulting in a missing match.

Possible solution

How to reproduce the issue
Have a proxy defined via environment variables (HTTP_PROXY resp. HTTPS_PROXY), Nock will no longer match the request since the incoming url will consist of both the proxy url and the actual url. Run the example below locally with a value set vor HTTP_PROXY.

Runkit: Example link

Having problem producing a test case? Try and ask the community for help. If the test case cannot be reproduced, the Nock community might not be able to help you.

Does the bug have a test case?

Versions

Software Version(s)
Nock 13.0.5
Node 14.8.0
TypeScript
@mastermatt
Copy link
Member

This seems related to #2089

It's important to note that Node itself does not modify requests based on HTTP_PROXY/HTTPS_PROXY. You're probably using a client that's doing it, your runkit uses Axios for example, which does follow the env vars.

Nock can still match these requests, it's just that you have to modify the scope to match how the client is modifying the request (NB. how those env vars are used is not standardized, it's just a widely used convention).

The preference with Nock is to stay as close to native Node as possible. Implementing it in Nock before it's part of core Node would more than likely come with a slew of gotchas and caveats.
Personally, I would prefer to not add this unless there was a much larger demand for the feature.

@stale
Copy link

stale bot commented Jul 1, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. We try to do our best, but nock is maintained by volunteers and there is only so much we can do at a time. Thank you for your contributions.

@stale stale bot added the stale label Jul 1, 2021
@stale stale bot closed this as completed Jul 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants