1

I want to send HTTPS POST requests through Node using the https module, and I want to capture them with Fiddler. How can I do this? I've found a few pieces of sample code, but they all use other modules like the requests library.

Jack M
  • 4,769
  • 6
  • 43
  • 67
  • The very same way as with http, https://stackoverflow.com/questions/3862813/how-can-i-use-an-http-proxy-with-node-js-http-client . Node doesn't have to be aware of Fiddler. It just need to send requests through its proxy, with `https`, or `request`, or anything else. – Estus Flask Oct 26 '18 at 20:34
  • @estus That answer doesn't seem to work. The intended usage of the options seems to be for `host` to be `example.com` and for `path` to be `pages/example.html`, say. You can't put the entire URL in the `path` and stick the proxy in `host`. I get a ECONNREFUSED error. – Jack M Oct 26 '18 at 21:45

1 Answers1

0

Here is something that I had used. You will need to require the https module from node. create a options obj like below.

options = {
    host: 'host',
    path: 'uri',
    port: 'port',
    method:'POST',
    headers: {'headerName':value}};
   }   

create a request object

  var call = https.request(options, callback); 
  call.write(payload);
  call.end();

payload is your post data, the callback function is executed once the https call is complete.

xan_z
  • 226
  • 1
  • 9
  • What should the values of host, path, and port be? – Jack M Oct 26 '18 at 20:45
  • that is location of the service you want to submit your HTTP/S post to. – xan_z Oct 26 '18 at 20:50
  • So then where do you specify the address and port of Fiddler's proxy? Are you sure you've understood the question? – Jack M Oct 26 '18 at 20:51
  • If I understood correct - you mean fiddler - HTTP debugging proxy server application - this should be able to pick up the traffic from your app when you make the outbound call. - and setup the fiddler proxy detail at node level - Try this https://weblogs.asp.net/dixin/use-fiddler-with-node-js – xan_z Oct 26 '18 at 20:55