Request: How to configure proxy with authentication?

Created on 11 May 2014  ·  4Comments  ·  Source: request/request

Hi, i need to configure my proxy with authentication, something like this:

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

How can i set this proxy configuration when i make a request?
I tried but got no success, if anyone can give me an example would be a great help
thanks

Most helpful comment

@uvenkat19 my code looks like:

//...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')

All 4 comments

try something like
var proxiedRequest = request.defaults({proxy: "http://proxyuser:[email protected]:8080"});

@tekay thank you, this worked well

@victor0402

can u please past the content of the file where you made changes ?

and if you know, please tell me how to bypass the request to another component which is runnig on XXXX port ?

@uvenkat19 my code looks like:

//...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')
Was this page helpful?
0 / 5 - 0 ratings