0

I am using a next js node server as my app. And a ngnix as my https server with self-signed certificate in which my API node server is at behind.

But I am getting a self-signed certificate error.

enter image description here

So, in my next js , I will contact the https server either by fetch and axios. for example.

enter image description here

enter image description here

Is there a easy way on how to get ride of it without buying SSL from real CA?

What I have tried:

This problem couldn't be by pass thru chrome insecure content enabling since it is a server error.

I am guessing this could be achieved from either setting node server / fetch or axios. But I am so new on this kind of problem.

second update

process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = 0; 

works to get rid of the fetch error:

But now it shown this error with put method:

net::ERR_CERT_AUTHORITY_INVALID

enter image description here

What I have done is to put process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = 0; on every api call.

For example

   try {
      process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = 0;
      const res = await axios.put(url);
     
    } catch (error) {
      console.log(error);
    }

I am still looking for a solution.

James Z
  • 12,104
  • 10
  • 27
  • 43
jason
  • 93
  • 7
  • 2
    Please post relevant code as text and not images. – ewong Feb 23 '22 at 04:25
  • Does this answer your question? [Ignore invalid self-signed ssl certificate in node.js with https.request?](https://stackoverflow.com/questions/10888610/ignore-invalid-self-signed-ssl-certificate-in-node-js-with-https-request) – ewong Feb 23 '22 at 04:26
  • not yet, please , seems this only work with fetch error. But will keep looking for solution. thanks – jason Feb 23 '22 at 05:01

0 Answers0