4

I am using axios as an HTTP client for node.js

I am using a proxy on localhost and port 8888 so I can sniff network traffic with Charles Proxy for debugging.

 axios.get(`http://example.com',
           { proxy: { host: '127.0.0.1', port: 8888 })
    .then(result => { // })
    .catch(error => { console.log(error) })

With this configuration, I often receive this error message:

Error: Hostname/IP doesn't match certificate's altnames:

I read here: Node.js Hostname/IP doesn't match certificate's altnames that I have to configure node.js like this to disable security checks:

{ rejectUnauthorized : false }

My question is how and where exactly do I make that configuration?

Community
  • 1
  • 1
etayluz
  • 15,920
  • 23
  • 106
  • 151

1 Answers1

-1

I do not know if you solve that. I hope you did. If not, for a known server as it is not safe to do that:

process.env.NODE_TLS_REJECT_UNAUTHORIZED = 0;

You can put this code in the file that is calling that server.

Samuel
  • 781
  • 5
  • 22