How can I set a proxy using Fetch API. I'm developing a node.js application and I'd like to have a look at the response body of an HTTPS response. I'm using this npm package that uses node http inside: https://www.npmjs.com/package/isomorphic-fetch
I tried to set the env variables like:
set https_proxy=http://127.0.0.1:8888
set http_proxy=http://127.0.0.1:8888
set NODE_TLS_REJECT_UNAUTHORIZED=0
but it seems to work only with request NPM node module.
I always get the following message:
http://127.0.0.1:8888
(node:30044) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): FetchError: request to https://www.index.hu failed, reason: read ECONNRESET
@jimliang has posted a solution for node-fetch
. He
used https://github.com/TooTallNate/node-https-proxy-agent
fetch('https://www.google.com',{ agent:new HttpsProxyAgent('http://127.0.0.1:8580')})
.then(function(res){
//...
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With