Using proxy like fiddler with fetch api
12,548
@jimliang has posted a solution for node-fetch
. He
fetch('https://www.google.com',{ agent:new HttpsProxyAgent('http://127.0.0.1:8580')})
.then(function(res){
//...
})
Author by
Lajos
Updated on June 19, 2022Comments
-
Lajos almost 2 years
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