Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upAxios proxy is not working. #2072
Comments
This comment has been minimized.
This comment has been minimized.
I can confirm. Full post on https://stackoverflow.com/questions/55981040/axios-https-request-over-a-proxy I tried the proxy param, which is apparently not supported in browser, but at least I tried : const axios = require('axios');
var res = await axios.get('https://api.ipify.org?format=json', {
proxy: {
host: 'proxy-url',
port: 80,
auth: {username: 'my-user', password: 'my-password'}
}
});
console.log(res.data); // gives my ip and not the proxy's one And also with the httpsAgent param : const axios = require('axios');
const HttpsProxyAgent = require('https-proxy-agent')
var agent = new HttpsProxyAgent('http://my-user:my-pass@proxy-url:port');
var res = await axios.get('https://api.ipify.org?format=json', {
httpsAgent: agent,
});
console.log(res.data); // gives my ip and not the proxy's one None of them work. |
This comment has been minimized.
This comment has been minimized.
+1 |
This comment has been minimized.
This comment has been minimized.
+1 |
This comment has been minimized.
This comment has been minimized.
+1 not working in version .19 |
This comment has been minimized.
This comment has been minimized.
i did 3 things that got it working.
first 2 didn't help without the last one. |
This comment has been minimized.
This comment has been minimized.
Thank you for that ! Next time i'll work on proxies i'll take a look. I have been struggling for an entire day trying to make this work, that was in april, but I finally switched to another library. |
This comment has been minimized.
This comment has been minimized.
Axios default.proxy settings don't work on Chrome. |
This comment has been minimized.
This comment has been minimized.
Axios (v.19) is not working with our corporate proxy for https requests. We use a squid proxy and it returns a protocol error in our case. You can reproduce the error in node (with a public squid proxy) using latest Axios and an Axios version using 'https-proxy-agent': run: create file 'index.js' with content: const axiosDefaultConfig = {
baseURL: 'https://jsonplaceholder.typicode.com/posts',
proxy: {
host: '142.93.165.82',
port: 8080,
protocol: 'http'
}
};
const axios = require ('axios').create(axiosDefaultConfig);
axios.get('42')
.then(function (response) {
console.log('Response with axios was ok: ' + response.status);
})
.catch(function (error) {
console.log(error);
});
const axiosFixed = require ('axios-https-proxy-fix').create(axiosDefaultConfig);
axiosFixed.get('42')
.then(function (response) {
console.log('Response with axios-https-proxy-fix was ok: ' + response.status);
})
.catch(function (error) {
console.log(error);
}); run Then you can see in console log that Axios fails with a protocol error while the modified Axios version using https-proxy-agent succeeds. |
Describe the bug
I have installed anyProxy 3rd party proxy ( http://anyproxy.io/en/#install )
When I type
anyproxy
in my command line then my proxy starts on http://localhost:8001and I have also preview of proxy status on http://localhost:8002.
On the Frontend site, I'm using axios like:
Here is a simplified version of this:
https://codesandbox.io/s/j35zl05lk5
But the request is omitting proxy and is sent directly:

It behaves like the axios proxying functionality would not be even working.
I also tried stuff like:
But it gives me the same result as the previous one.
Also tried npm dependency called "axios-https-proxy-fix", but with the same result.
Expected behavior
Proxying request to the proxy server.
Environment: