7

i'm trying to capture node.js http traffic with a protocol analyser (Charles) but can't get node to use the proxy. Is there some way to get nodes http and https modules to use a proxy?

I'm using OSX by the way

Chris
  • 39,719
  • 45
  • 189
  • 235

2 Answers2

5

Thanks Chris in my case I was using Charles and Request module. There is a handle proxy option to put your charles port.

So to find your port in the Charles menu Proxy->Proxy Settings->Http Proxy

Use this port number in any request eg:

request.get(url, {
  'proxy': 'http://localhost:<charles-proxy-port>'
}, function (error, response, body) {
   //did you see me in Charles??
});
Community
  • 1
  • 1
imp
  • 1,110
  • 8
  • 13
3

Figured it out. I was following the instructions from How can I use an http proxy with node.js http.Client? And i thought i needed to use https to access the proxy. But if i use http to access the proxy, and pass eg 'path: 'https://www.google.com/accounts/OAuthGetRequestToken', then it works...

Community
  • 1
  • 1
Chris
  • 39,719
  • 45
  • 189
  • 235