nodejs - error self signed certificate in certificate chain

前端 未结 6 1747
孤街浪徒
孤街浪徒 2020-12-07 22:51

I am facing a problem with client side https requests.

A snippet can look like this:

var fs = require(\'fs\');
var https = require(\'https\');

var o         


        
6条回答
  •  臣服心动
    2020-12-07 23:25

    You can fix this issue using NODE_TLS_REJECT_UNAUTHORIZED=0 in the terminal or inserting the following line within the JS file.

    process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = 0;
    

    Beware that this a hack and it should not be used in production.

    If you are using windows then run the following command in the command prompt:

    set NODE_TLS_REJECT_UNAUTHORIZED=0 
    

    After that, npm install will work.

提交回复
热议问题