How to configure axios to use SSL certificate? : <p>I'm trying to make a request with axios to an api endpoint and I'm getting the following error: <code>Error: unable to verify the first certificate</code></p>

<p>It seems the https module, which axios uses, is unable to verify the SSL certificate used on the server.</p>

<p>When visiting the server with my browser, the certificate is valid and I can see/download it. I can also make requests to the api on my browser through https.</p>

<p>I can work around it by turning off verification. This code works.</p>

<pre><code>const result = await axios.post(
    `https://${url}/login`,
    body,
    {
      httpsAgent: new https.Agent({
        rejectUnauthorized: false
      })
    }
  )
</code></pre>

<p>Problem is, this doesn't verify the SSL certificate and therefore opens up security holes.</p>

<p>How can I configure axios to trust the certificate and correctly verify it?</p>
