I have problem with creating node.js application based on express with http-auth module.
It's a posslible create Middleware for this http-auth library i have this code
//Configure Middlewares
logger.configure(function() {
//All output has content type json
logger.use(function(req, res, next) {
res.contentType('application/json');
next();
});
//Create digest auth middleware
logger.use(function(req, res, next){
digest.apply();
next();
});
});
after appling this when i want connect to site i will get
TypeError: Cannot read property 'headers' of undefined
Is there any solution for this problem or use another method, i need have digest auth for whole application.
Thank you
I think apply() is expecting the request object (hence it can't read the headers);
try this syntax:
digest.apply(req, res, function(username) {
});