I'm sending an http request over a proxy an need to add username and password to my request. How do I correctly add these values to my options block?
This is my code:
var http = require('http');
var options = {
port: 8080,
host: 'my.proxy.net',
path: '/index',
headers: {
Host: "http://example.com"
}
};
http.get(options, function(res) {
console.log("StatusCode: " + res.statusCode + " Message: " + res.statusMessage);
});
Currently the response is StatusCode: 307, Message: Authentication Required.
I tried to add username and password to my options but it doesn't work:
var options = {
port: 8080,
host: 'my.proxy.net',
username: 'myusername',
password: 'mypassword',
path: '/index',
headers: {
Host: "http://example.com"
}
};
Additional Info: I don't have much information about the proxy, but in another case this authentication method worked:
npm config set proxy http://username:[email protected]:8080