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

axios uses http adaptor when https_proxy is set #1885

Closed
PavelPolyakov opened this issue Nov 21, 2018 · 1 comment
Closed

axios uses http adaptor when https_proxy is set #1885

PavelPolyakov opened this issue Nov 21, 2018 · 1 comment

Comments

@PavelPolyakov
Copy link

PavelPolyakov commented Nov 21, 2018

First I stumbled upon the socket hangs up issue. So I found this PR, which was merged, but never released: #959 .

So I installed axios@next to check if this issue is fixed there. And found another problem.

When http_proxy and https_proxy is set, and in my case it's socks5:// proxy - axios can not get the url.

This is how I set proxy:

export http_proxy=socks5://localhost:9999/ https_proxy=socks5://localhost:9999/

This is the code:

const axios = require('axios');
const https = require('https');

const httpsAgent = new https.Agent({
  rejectUnauthorized: false,
});

async function main() {
  const response = await axios.get('https://api.jsonbin.io/b/5bf56cf6bc03835906819ee8', { httpsAgent });
  console.log(response.data);
}

main();

And here is the error:

(node:18469) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 3): Error: Protocol "http:" not supported. Expected "https:"

I'm sure it's about the proxy, since when I unset https_proxy - everything works.
It may be the issue, that I use socks5:// as protocol, but I'm not sure.

Context

  • axios version: axios@0.19.0-beta.1
  • Environment: v8.9.4
@chinesedfan
Copy link
Collaborator

Closed in favor of #1981.

@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

No branches or pull requests

2 participants