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

I find the following to be nifty. The request module reads proxy information from the windows environment variable.

Typing the following in the windows command prompt, will set it for the lifetime of the shell. You just have to run your node app from this shell.

set https_proxy=http://127.0.0.1:8888 
set http_proxy=http://127.0.0.1:8888
set NODE_TLS_REJECT_UNAUTHORIZED=0

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

If you want to montior outgoing reqeusts from node you can use the request module

and just set the proxy property in the options, like that

request.post('http://204.145.74.56:3003/test', {
headers :{ 'content-type' : 'application/octet-stream'}, 
'body' : buf ,
 proxy: 'http://127.0.0.1:8888'
}, function() {
   //callback
});

8888 is the default port , of fiddler .