Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
14
rated 0 times [  19] [ 5]  / answers: 1 / hits: 28882  / 13 Years ago, mon, january 2, 2012, 12:00:00

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 debug the http requests much like I would using Fiddler for JavaScript in the browser.



Just be clear, I am not trying to create a proxy nor proxy requests received by a server. I want to route requests made by http.request() through a proxy. I would like to use Fiddler to inspect both the request and the response as I would if I was performing the request in a browser.


More From » node.js

 Answers
91

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) {
...
});

[#88283] Friday, December 30, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jaylynbrynnk

Total Points: 706
Total Questions: 98
Total Answers: 91

Location: Israel
Member since Thu, Jan 7, 2021
3 Years ago
jaylynbrynnk questions
Thu, Jan 28, 21, 00:00, 3 Years ago
Thu, Dec 24, 20, 00:00, 4 Years ago
Sun, Jun 14, 20, 00:00, 4 Years ago
;