Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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

share|improve this question
Is it an HTTP or SOCKS proxy? – nFreeze 2 days ago
it is an HTTP proxy – Agus 2 days ago

1 Answer

up vote 2 down vote accepted

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.
  }
})
share|improve this answer
It is great for http, but I need https requeqes – Agus 2 days ago
It works great with ssl too. – nFreeze 2 days ago
1  
Example updated – nFreeze 2 days ago

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.