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

Using HTTP proxy for HTTPS address does not start a HTTP Connection #6330

Open
HoffmannP opened this issue Mar 28, 2024 · 1 comment
Open

Comments

@HoffmannP
Copy link

HoffmannP commented Mar 28, 2024

Describe the bug

When I want to access an HTTPS ressource via a HTTP Proxy the connection fails due to axios not starting a HTTP Connection via which both sides can talk but instead tries the "usual" connection to the proxy with path as the target.

To Reproduce

https://codesandbox.io/p/devbox/admiring-panini-rp2pyr

Code snippet

import axios from "axios"

const instance = axios.create({
  proxy: {
    protocol: 'http',
    host: '23.152.40.14',
    port: 3128
  }
})

instance.post(
  'https://nmshd-bkb.demo.meinbildungsraum.de/api/v1/Challenges',
  { test: 1 }
).then(
  response => { console.log('Success\n', response.data) }
).catch(
  error => {
    console.error('Error\n', error.response ? error.response.data : error.cause)
  }
)

Expected behavior

It works

Axios Version

1.6.7

Adapter Version

http

Browser

No response

Browser Version

No response

Node.js Version

19.9.0

OS

Linux Mint 21.3

Additional Library Versions

No response

Additional context/Screenshots

No response

@HoffmannP
Copy link
Author

HoffmannP commented Mar 28, 2024

But it is possible to use that server to get that response if the correct way is applied: https://codesandbox.io/p/devbox/lively-meadow-j3834n

import axios from "axios";
import HttpsProxyAgent from "https-proxy-agent";

const instance = axios.create({
  httpsAgent: new HttpsProxyAgent.HttpsProxyAgent("http://23.152.40.14:3128"),
});

instance
  .post("https://nmshd-bkb.demo.meinbildungsraum.de/api/v1/Challenges", {
    test: 1,
  })
  .then((response) => {
    console.log("Success\n", response.data);
  })
  .catch((error) => {
    console.error(
      "Error\n",
      error.response ? error.response.data : error.cause,
    );
  });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant