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

HTTP proxy authentication #476

Closed
peruukki opened this issue Oct 10, 2016 · 7 comments · Fixed by #483
Closed

HTTP proxy authentication #476

peruukki opened this issue Oct 10, 2016 · 7 comments · Fixed by #483

Comments

@peruukki
Copy link

HTTP proxy support was added in #366, but the proxy configuration only takes into account the proxy host and port. We are running in an environment that requires authenticating to the proxy, and as far as I understood, axios doesn't support that. We are using the standard http_proxy and https_proxy environment variables with the credentials in the URL, like http://proxy-user:proxy-password@proxy-host:proxy-port, and passing that works as expected with e.g. superagent-proxy.

So I'm requesting to have support for HTTP proxy authentication, preferably even taking the credentials automatically from HTTP proxy environment variables.

@mzabriskie
Copy link
Member

Would be happy to accept a PR for this.

@mawrkus
Copy link
Contributor

mawrkus commented Oct 11, 2016

Hi guys,
First of all @mzabriskie: thanks for the good work on Axios, it's great library!
I've been facing the same issue and been able to make it work properly by:

  1. adding the proper "Host" and "Proxy-Authorization" fields to the headers and
  2. adding "hostname" to the options object in Axios http adapter
    I hope to find some time to submit a PR this week. I have the feeling it should be straightforward but I suspect it might have other implications.

@mawrkus
Copy link
Contributor

mawrkus commented Oct 14, 2016

Just submitted the PR, let me know how it looks like.

@peruukki
Copy link
Author

Great, thanks @mawrkus!

@ghost
Copy link

ghost commented Nov 9, 2018

At what time in the lifetime of my nodejs script executing must process.env.http_proxy or process.env.https_proxy be set? My proxy settings don't appear to work. Also, I'm using v0.11.0 of axios, and I'm not sure how to tell what version this PR is a part of.

@peruukki
Copy link
Author

According to the changelog, the fix was included in v0.15.3. Though it still wouldn't work in our environment and I couldn't figure out why in a reasonable time, so we kept using superagent instead. 🤷‍♂️

I've always seen environment variables being set before/when the application starts, I'm not sure if it's possible to set them afterwards (and it doesn't sound like a good idea anyway).

@ghost
Copy link

ghost commented Nov 12, 2018

Thanks a bunch @peruukki !

Weird yeah I’ve just been using request-native-promise instead 🤷‍♂️

I see why one should normally not set env vars after script starts but I wrote a CLI program that optionally let’s the user configure proxy settings for the rest of the lifetime of the script

The root problem here tho was version of library I was using, setting env vars after script starts was just accidental red herring

Thank u!!

@axios axios locked and limited conversation to collaborators May 22, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants