使用https-proxy-agent
npm i https-proxy-agent
在代码中使用
需要加上rejectUnauthorized: false
,否则可能会出现错误unable to verify the first certificate
if(url.startsWith("https")){
req= https.request(url,{
method: "POST",
rejectUnauthorized: false,
headers: headers ,
agent: agent
});
}else {
req= http.request(url, {
method: "POST",
headers: headers,
agent: agent
});
}