title: Getting ERR_CERT_AUTHORITY_INVALID with axios
body: <p>I'm trying to do a post request via https with vue-axios.
  However, since i'm using a self-signed certificate that i created, i'm getting the following error:</p>
  
  <blockquote>
    <p>net::ERR_CERT_AUTHORITY_INVALID</p>
  </blockquote>
  
  <p>Upon searching i found that most people solve this by doing the following </p>
  
  <pre><code>const instance = axios.create({
    httpsAgent: new https.Agent({  
      rejectUnauthorized: false
    })
  });
  instance.get('https://something.com/foo');
  
  // At request level
  const agent = new https.Agent({  
    rejectUnauthorized: false
  });
  axios.get('https://something.com/foo', { httpsAgent: agent });
  </code></pre>
  
  <p>I tried both option but didn't have any success with them.
  I used the npm https module for the https.Agent.</p>
  
  <p>Does anyone know how to solve this problem? or should I just change from axios to other modules?</p>
  
  <p>edited:</p>
  
  <p>the piece of code I'm running with the error at the moment:</p>
  
  <pre><code>const axiosInstance = axios.create({
    baseURL: 'https://localhost:5000',
    httpsAgent: new https.Agent({
      rejectUnauthorized: false
    }),
  });
  axiosInstance.post('/user', LoginRequest, 
    { headers: { 'Content-Type': 'application/json' } })
      .then(response =&gt; this.assignLogin(response.data));
  </code></pre>
  
  <p>tried to change to a module named needle and use https but had the same error:</p>
  
  <p>needle:</p>
  
  <pre><code>      const headers = { 'Content-Type': 'application/json' };
        const options = {
            method: 'POST',
            headers: headers,
            rejectUnauthorized: false,
            requestCert: true,
            agent: false,
            strictSSL: false,
        }
        needle.post('https://localhost:5000/user', LoginRequest, options).on('end', function() { })
  </code></pre>
  
  <p>https:</p>
  
  <pre><code>const options = {
           hostname: 'localhost',
           port: 5000,
           path: '/user',
           strictSSL: false,
           rejectUnauthorized: false,
           secureProtocol: 'TLSv1_method',
           method: 'POST',
           headers: {
             'Content-Type': 'application/json',
           },
         };
         const req = https.request(options, (res) =&gt; {
           console.log('statusCode:', res.statusCode);
           console.log('headers:', res.headers);
  
           res.on('data', (d) =&gt; {
             this.assignLogin(d);
           });
         });
         req.on('error', (e) =&gt; {
           console.error(e);
         });
         req.write(LoginRequest);
         req.end();
  </code></pre>