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

Protocol not parsed when setting proxy config from env vars #3070

Merged
merged 4 commits into from Dec 3, 2020
Merged

Protocol not parsed when setting proxy config from env vars #3070

merged 4 commits into from Dec 3, 2020

Conversation

@jonathanfoster
Copy link
Contributor

@jonathanfoster jonathanfoster commented Jun 27, 2020

This PR resolves the issue when setting proxy config from env vars, the proxy config protocol is not set based on the env var URL. This causes all proxy server connections to use HTTP and results in invalid request errors.

If you set HTTPS_PROXY to an HTTPS URL...

export HTTPS_PROXY=https://localhost:8080

then the proxy config will be set without protocol, which is used later on to initiate the proxy connection.

proxy: {
  host: 'localhost'
  port: 8080
}

The proxy config should include protocol when parsing from env vars.

proxy: {
  host: 'localhost'
  port: 8080,
  protocol: 'https'
}

To reproduce this issue, create a local HTTPS proxy with mitmproxy and set HTTPS_PROXY to https://localhost:8080. mitmproxy will respond with a 400 and the error message HTTP protocol error in client request: Invalid request scheme: https.

@jonathanfoster
Copy link
Contributor Author

@jonathanfoster jonathanfoster commented Jun 27, 2020

I just realized this PR is a dupe of #2562. I would still pull this one in though since it includes unit tests.

@jsevedge
Copy link

@jsevedge jsevedge commented Sep 2, 2020

+1, @jonathanfoster was just considering creating PR myself until I came across yours. Adding protocol supports will provide parity with deprecated requests project. Any idea when this will be merged?

@jonathanfoster
Copy link
Contributor Author

@jonathanfoster jonathanfoster commented Sep 2, 2020

Looks like @chinesedfan removed the work in progress label a few days ago. I’m not sure what the workflow is like, but this makes me think it won’t make it into the next release.

@chinesedfan or @jasonsaayman, can you guys provide an update? Anything else we need to do to ship this PR?

@jasonsaayman
Copy link
Collaborator

@jasonsaayman jasonsaayman commented Sep 3, 2020

Hi @jonathanfoster

I think it will make it into the next release, I am starting to collect pull requests for 0.21 should get here soon.

Thanks

@jonathanfoster
Copy link
Contributor Author

@jonathanfoster jonathanfoster commented Nov 14, 2020

@jasonsaayman Looks like this one didn't make it into 0.21. Anything I can do to help get it in 0.22? This PR fixes a huge pain point for anyone using axios behind a corporate proxy.

@jasonsaayman jasonsaayman added this to the v0.21.1 milestone Nov 19, 2020
Copy link
Collaborator

@jasonsaayman jasonsaayman left a comment

This looks good to me, has tests, and does not seem to break backward compatibility.

@jasonsaayman
Copy link
Collaborator

@jasonsaayman jasonsaayman commented Nov 19, 2020

@chinesedfan can you have a look let me know if we can merge?

@jasonsaayman jasonsaayman added this to In Progress in v0.21.1 Nov 19, 2020
Copy link
Collaborator

@chinesedfan chinesedfan left a comment

Looks good to me, except for a few suggestions.

README.md Show resolved Hide resolved
test/unit/adapters/http.js Show resolved Hide resolved
lib/adapters/http.js Show resolved Hide resolved
@chutchi2
Copy link

@chutchi2 chutchi2 commented Dec 1, 2020

It looks like all the requested changes have been completed @chinesedfan. Bumping this thread as a follow up.

@jasonsaayman jasonsaayman merged commit e426910 into axios:master Dec 3, 2020
1 check passed
1 check passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@jasonsaayman jasonsaayman moved this from In Progress to Done in v0.21.1 Dec 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Linked issues

Successfully merging this pull request may close these issues.

None yet

5 participants