Question

I am having difficulty viewing the information exchanged between a Node js application and an API.

The developers are using the request module. Looking at the readme there is an option called 'proxy':

proxy - An HTTP proxy to be used. Supports proxy Auth with Basic Auth, identical to support for the url parameter (by embedding the auth info in the uri)

However when I add in the proxy as an option it seems to be discarded because while the request is passed to the server I see no information in my http proxy (Charles or Fiddler)

The options I am using are:

exports.defaultOptions = function(){
  return {
    host: config.apiHost, // API url to connect too
    headers: { 'Content-Type': 'application/json' },
    method: 'POST', // Default method
    port: config.apiPort, // API port number to connect too
    proxy: 'http://192.168.2.183:8888'
  };
};

I have tried other methods of debugging the traffic (tunneling agents, proxychains) but these all seem to result in a CONNECT method rather than a GET or a POST.

If anyone has any experience of using the proxy option, or indeed if I have fundamentally misunderstood the implementation or use of the proxy option, please let me know.

Thanks

Was it helpful?

Solution

Use 'url' instead of 'host'. I'm assuming from the inline comment, it is a full url to the endpoint of the api.

exports.defaultOptions = function(){
  return {
    url: config.apiHost, // API url to connect too
    headers: { 'Content-Type': 'application/json' },
    method: 'POST', // Default method
    port: config.apiPort, // API port number to connect too
    proxy: 'http://192.168.2.183:8888'
  };
};

From docs : uri || url - fully qualified uri or a parsed url object from

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top