Can a proxy (like fiddler) be used with Node.js's ClientRequest

前端 未结 6 735
栀梦
栀梦 2020-12-23 02:13

Can node.js be setup to recognize a proxy (like Fiddler for example) and route all ClientRequest\'s through the proxy?

I am using node on Windows and would like to d

6条回答
  •  甜味超标
    2020-12-23 02:48

    To route your client-requests via fiddler, alter your options-object like this (ex.: just before you create the http.request):

    options.path = 'http://' + options.host + ':' + options.port + options.path;
    options.headers.host = options.host;
    options.host = '127.0.0.1';
    options.port = 8888;
    
    myReq = http.request(options, function (result) {
        ...
    });
    

提交回复
热议问题