How to use axios to make an https call?

Axios https proxy support is borked if using https proxies. Try passing the proxy through httpsProxyAgent using http.

const axios = require('axios'); 
const httpsProxyAgent = require('https-proxy-agent');

const httpsAgent = new httpsProxyAgent('http://username:pass@myproxy:port');
// or const httpsAgent = new httpsProxyAgent({ host: 'myproxy', port: 9999 });

const config = {
  url: 'https://google.com',
  httpsAgent
}

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.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)