最佳答案
我使用 Mikeal 的请求(https://github.com/mikeal/request)向服务器发送 https 请求。但是,我不断收到 CERT _ HAS _ EXPIRED 的授权错误。
request({
url: 'https://www.domain.com/api/endpoint',
strictSSL: false
}, function(error, response, body) {
if(!error && response.statusCode == 200) {
res.json(JSON.parse(body));
} else {
res.json(response.statusCode, {'error': 'error'})
}
});
我尝试将 strictSSL 设置为 true 和 false,两者都输出 CERT _ HAS _ EXPIRED 相同的错误。是什么导致了这个问题,有没有办法在 nodejs 中修复它?