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 req with proxy + ca doesn't work #6318

Open
subhankarc opened this issue Mar 25, 2024 · 1 comment
Open

http req with proxy + ca doesn't work #6318

subhankarc opened this issue Mar 25, 2024 · 1 comment

Comments

@subhankarc
Copy link

subhankarc commented Mar 25, 2024

Describe the bug

Describe the issue

I'm trying to use a proxy with a ca cert but always throws an error

This is working fine with superagent and got, but Axios does not seem to work.

Reopening this issue, as it was also reported in #4963 but the issue was closed without resolution.

To Reproduce

No response

Code snippet

const axios_options = {
        maxRedirects: 0, //no followRedirect
        headers: options.headers,
        url: options.url,
        method: options.method,
        timeout: options.timeout || 2000
    };

    if (options.params) {
        axios_options.params = options.params;
    }

    if (options.form) {
        const formData = options.form;
        axios_options.data = new url.URLSearchParams(formData).toString();
    }

    if (options.https) {
        axios_options.httpsAgent = new https.Agent({
            cert: options.https.certificate,
            key: options.https.key
        });
    }

    HERE you can change all axios configs to add proxy, etc
    axios_options.proxy = {
        protocol: 'http',
        host: 'proxy.com',
        port: 8886,
        auth: {
            username: 'xyz',
            password: 'abcd'
        }
    }

    try {
        const result = await axios(axios_options);
        const json = result.data;
    } catch (e) {

    }

Expected behaviour

No response

Axios Version

1.6.5

Adapter Version

No response

Browser

No response

Browser Version

No response

Node.js Version

Node 20

OS

No response

Additional Library Versions

No response

Additional context/Screenshots

No response

@Thorvarium
Copy link

Same here. Works with superagent

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

2 participants