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

Support proxy option instead of HTTP_PROXY env variable #520

Closed
vamcc opened this issue Jan 10, 2023 · 4 comments · Fixed by #614
Closed

Support proxy option instead of HTTP_PROXY env variable #520

vamcc opened this issue Jan 10, 2023 · 4 comments · Fixed by #614
Assignees
Labels
type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@vamcc
Copy link

vamcc commented Jan 10, 2023

Is your feature request related to a problem? Please describe.
Using HTTP_PROXY env variable will affect other requests which may also come from some other third-party packages. And not every package support NO_PROXY env variable. In my scene, I just want to proxy request from googleapis which depend on gaxios and keep other requests called directly.
Describe the solution you'd like
Support proxy variable in options instead of global env variable, so that developers can keep the proxy in control.

gaxios.request({
  url: 'xxx',
  proxy: 'yyy'
})

Describe alternatives you've considered
I tried to list all the third-party url and use NO_PROXY to resolve this problem, but I failed. Not every package support NO_PROXY
Additional context

@vamcc vamcc added priority: p3 Desirable enhancement or fix. May not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. labels Jan 10, 2023
@bcoe
Copy link
Contributor

bcoe commented Jan 11, 2023

@vamcc this library should be supporting NO_PROXY, could you provide a minimal example that is failing for you?

@bcoe bcoe added type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. and removed priority: p3 Desirable enhancement or fix. May not be included in next release. labels Jan 11, 2023
@vamcc
Copy link
Author

vamcc commented Jan 13, 2023

@vamcc this library should be supporting NO_PROXY, could you provide a minimal example that is failing for you?

Yes, but not every package use gaxios as its request client. Maybe some other request clients just support 'HTTP_PROXY’ but not 'NO_PROXY'.
I found options.agent below, does it work?

{
  agent: new HttpsProxyAgent(proxy),
}

Here is the source code about opts.agent and proxy.
I doubt is this an alternative provided for developers?😂

@drmrbrewer
Copy link

I agree that it would be nice to be able to specify a proxy on a per-request level via a simple proxy: 'http://my.proxy.com' option, rather than using a global env var as suggested here, which will apply to all requests made in that environment.

Having said that, it does indeed seem to be possible already to set a per-request proxy using agent: new HttpsProxyAgent('http://my.proxy.com') but this requires the extra leg-work of installing the https-proxy-agent module and importing with import HttpsProxyAgent from 'https-proxy-agent'... not a massive deal but a proxy option would be nicer IMHO!

@sofisl sofisl removed the type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. label May 23, 2023
@danielbankhead
Copy link
Member

danielbankhead commented Apr 6, 2024

Resolving shortly via:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants