3

I want to make an https request call from node.js, using the standar https Client. But I cannot reach the remote server directly from my network and need to go through a proxy.

How do I tell node.js to use the proxy? I tried option as following the post

{ path : 'https://api.xxx.com:8081/token';
host : 'proxy-us.xxxx.com';
port : 8082;
method : POST_METHOD;
headers : {
    'host':  "api.xxx.com:8081"
}

But never reached

Community
  • 1
  • 1
Agus
  • 1,604
  • 2
  • 23
  • 48

1 Answers1

3

I am a big fan of Mikeal's request module. It makes http requests very easy and has many features such as proxy support, streaming, forms, auth and oauth signing. Here is a proxy example:

var request = require('request');
request({'url':'https://api.xxx.com:8081/token',
         'proxy':'http://proxy-us.xxxx.com:8082'}, function (error, response, body) {
  if (!error && response.statusCode == 200) {
    console.log(body) // Print the google web page.
  }
})
mr.freeze
  • 13,731
  • 5
  • 36
  • 42