I am trying to use axios with a proxy server to make an https call:
const url = "https://walmart.com/ip/50676589" var config = { proxy: { host: proxy.ip, port: proxy.port } } axios.get(url, config) .then(result => {}) .catch(error => {console.log(error)})
The proxy servers I am using are all in the United States, highly anonymous, with support for HTTP and HTTPS.
I am receiving this error:
{ Error: write EPROTO 140736580649920:error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol:../deps/openssl/openssl/ssl/s23_clnt.c:794:
In order to ensure that the problem is with axios and NOT the proxy, I tried this:
curl -x 52.8.172.72:4444 -L 'https://www.walmart.com/ip/50676589'
This totally works just fine.
How do I configure axios to work with proxies and https URL's?
To perform an HTTP POST request in Axios, call axios. post() . Making a POST request in Axios requires two parameters: the URI of the service endpoint and an object that contains the properties you wish to send to the server. For a simple Axios POST request, the object must have a url property.
What is Axios? Axios is a promise-based HTTP Client for node.js and the browser. It is isomorphic (= it can run in the browser and nodejs with the same codebase). On the server-side it uses the native node.js http module, while on the client (browser) it uses XMLHttpRequests.
Sending a PUT Request with Axios The simplest way to make the PUT call is to simply use the put() function of the axios instance, and supply the body of that request in the form of a JavaScript object: const res = await axios. put('/api/article/123', { title: 'Making PUT Requests with Axios', status: 'published' });
Axios https proxy support is borked if using https proxies. Try passing the proxy through [httpsProxyAgent][1]
using http.
var axios = require('axios'); let httpsProxyAgent = require('https-proxy-agent'); var agent = new httpsProxyAgent('http://username:pass@myproxy:port'); var config = { url: 'https://google.com', httpsAgent: agent } axios.request(config).then((res) => console.log(res)).catch(err => console.log(err))
Alternatively there is a fork of Axios that incorporates this: axios-https-proxy-fix but I'd recommend the first method to ensure latest Axios changes.
Try this. That work for me.
First
npm install axios-https-proxy-fix
Then
import axios from 'axios-https-proxy-fix'; const proxy = { host: 'some_ip', port: some_port_number, auth: { username: 'some_login', password: 'some_pass' } }; async someMethod() { const result = await axios.get('some_https_link', {proxy}); }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With