Using Axios & https-proxy-agent : Error: self signed certificate in certificate chain

2.9k views Asked by At

Here is my simple fetching code using axios and https-proxy-agent to use proxy server.

When I'm running this code:

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

const init = async() => {
    try {
        const url = 'https://www.myawesomeurl.com'
        response = await axios.get(url, {
            headers: {
                'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36'
            },

            proxy: false,
            httpsAgent: new HttpsProxyAgent.HttpsProxyAgent('http://MyLogin:[email protected]:24001')
        });

        console.log(response);
    } catch (error) {
        console.log(error)
    }
}

init();

When I'm running this script, I get the following error :

Error: self signed certificate in certificate chain

How can I solve this ? I read I could ignore SSL error, but I cannot figure out how to do that using https-proxy-agent...

Anyone could help me ?

0

There are 0 answers