electron http/https 使用 https-proxy-agent 請求設置代理


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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM