I have an nodejs app which use the http basic authentication in express.js.
In this app I make an http.get request to an external webpage to load and parse the html.
With the basic auth I get in each http.get(url, function(){})
request to the external host an error: "Unauthorized". If I remove the basic authentication, it works fine.
Anybody know's why I'm Unauthorized at an public resource if only my own server has this authentication?
e.g. (pseudocode):
with the express basic authentication, I'm getting "Unauthorized" as body from google.com. without the auth, I get the html
var auth = express.basicAuth(function(user, pass, callback) {
var result = (user === 'john' && pass === 'doe') ? true : false;
callback(null, result);
});
app.configure(function(){
app.use("/", auth, function(next) { next(); });
app.use("/", express.static(__dirname+'/html'));
});
http.get('http://google.com', function(res) {
res.setEncoding('utf8');
var body = '';
res.on('data', function (chunk) {
body = body + chunk;
});
res.on('end', function() {
cb(body);
});
}).on('error', function(err) {
cb('error', err);
});