我正在尝试将 axios 与代理服务器一起使用来进行 https 调用:
const url = "https://walmart.com/ip/50676589"
var config = { proxy: { host: proxy.ip, port: proxy.port } }
axios.get(url, config)
.then(result => {})
.catch(error => {console.log(error)})
我使用的代理服务器都在美国,高度匿名,支持 HTTP 和 HTTPS。
我收到此错误:
{ 错误:写入 EPROTO 140736580649920:错误:140770FC:SSL 例程:SSL23_GET_SERVER_HELLO:未知协议:../deps/openssl/openssl/ssl/s23_clnt.c:794:
为了确保问题出在 axios 而不是代理,我尝试了这个:
curl -x 52.8.172.72:4444 -L ‘ https://www.walmart.com/ip/50676589 ‘
这完全可以正常工作。
如何配置 axios 以使用代理和 https URL?
原文由 etayluz 发布,翻译遵循 CC BY-SA 4.0 许可协议
如果使用 https 代理,Axios https 代理支持就会失效。尝试使用 http 通过 httpsProxyAgent 传递代理。
或者,有一个 Axios 的分支合并了这个: axios-https-proxy-fix 但我推荐第一种方法以确保最新的 Axios 更改。