我正在尝试使用 Node 的请求模块向 https url 发出请求。下面的代码片段。
var request = require('request')
,r = request.defaults(
{'proxy':'https://localhost:8443',
strictSSL: false,
rejectUnauthorized: false,
});
function sendHttpsReq(){
r.get('https://my.https.url/api/model', function (error, response, body) {
if (!error && response.statusCode == 200) {
console.log(body);
}
});
}
Run Code Online (Sandbox Code Playgroud)
使用上面的代码,如果我使用http代理并发出http请求,代理服务器会收到请求。但对于通过 https 代理的 https url,代理服务器永远不会收到请求。我正在使用在本地服务器上运行的基于节点 http 代理的简单代理服务器。