Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

proxy authentication in node.js with module request

I'm trying to use the module request in my node.js app, and I need to configure proxy settings with authentication.

My settings are something like this:

proxy:{     host:"proxy.foo.com",     port:8080,     user:"proxyuser",     password:"123" } 

How can i set my proxy configuration when i make a request? Could someone give me an example? thanks

like image 561
Victor Avatar asked May 10 '14 19:05

Victor


People also ask

What is network proxy authentication?

The HTTP Proxy-Authenticate response header defines the authentication method that should be used to gain access to a resource behind a proxy server. It authenticates the request to the proxy server, allowing it to transmit the request further.


1 Answers

Here is an example of how to configure (https://github.com/mikeal/request/issues/894):

//...some stuff to get my proxy config (credentials, host and port) var proxyUrl = "http://" + user + ":" + password + "@" + host + ":" + port;  var proxiedRequest = request.defaults({'proxy': proxyUrl});  proxiedRequest.get("http://foo.bar", function (err, resp, body) {   ... }) 
like image 84
Victor Avatar answered Oct 08 '22 09:10

Victor