使用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
    });
}

相关文章:

  • 2021-06-10
  • 2021-07-19
  • 2022-12-23
  • 2022-12-23
  • 2021-11-21
  • 2021-07-18
猜你喜欢
  • 2021-10-03
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-02
  • 2022-12-23
相关资源
相似解决方案