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

Bunjs axios does not support proxy #12005

Open
zfcsoftware opened this issue Jun 20, 2024 · 0 comments · May be fixed by #12046
Open

Bunjs axios does not support proxy #12005

zfcsoftware opened this issue Jun 20, 2024 · 0 comments · May be fixed by #12046
Labels
bug Something isn't working needs triage

Comments

@zfcsoftware
Copy link

What version of Bun is running?

1.1.15+b23ba1fe1

What platform is your computer?

Linux 6.5.0-35-generic x86_64 x86_64

What steps can reproduce the bug?

The error occurs when using the HttpsProxyAgent library. When axios request is sent with proxy, bunjs ignores the proxy information and sends the request with the computer ip address. But Nodejs sends it with proxy information.
You can use any proxy for testing. The code was executed unchanged.

Code:

const axios = require('axios');
const { HttpsProxyAgent } = require('https-proxy-agent');
const httpsAgent = new HttpsProxyAgent(`http://<proxy-username>:<proxy-password>@<proxy-host>:<proxy-port>`)
axios.get('https://ipapi.co/json', {
    httpsAgent,
}).then(res => {
    console.log(res.data);

}).catch(err => {
    console.log(err.message);
})

Node.js Result
image
Bun Result
image

If we use axios' local proxy support instead, it doesn't pass auth and returns a 407 error.

Code:

const axios = require('axios');
axios.get('https://ipapi.co/json', {
    proxy: {
        protocol: 'http',
        host: "proxy-host",
        port: "proxy-port",
        auth: {
            username: "proxy-username",
            password: "proxy-password"
        }
    }
}).then(res => {
    console.log(res.data);

}).catch(err => {
    console.log(err.message);
})

Node.js Result:
image

Bun Result:
image

What is the expected behavior?

The expected behavior is that bun sends the request with a proxy like Node.js.

What do you see instead?

Bun HttpsProxyAgent library ignores proxy information. Axios' native proxy support also doesn't send username and password information. The same code works fine with Node.js but Bunjs doesn't use proxy.

Additional information

No response

@zfcsoftware zfcsoftware added bug Something isn't working needs triage labels Jun 20, 2024
@forcefieldsovereign forcefieldsovereign linked a pull request Jun 21, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs triage
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant