title: node.js Express with HTTP-AUTH
body: <p>I have problem with creating node.js application based on express with <a href="http://http-auth.info" rel="nofollow">http-auth</a> module.</p>
  
  <p>It's a possible create Middleware for this <strong>http-auth</strong> library I have this code:</p>
  
  <pre><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();
    });
  });
  </code></pre>
  
  <p>After applying this, when I connect to site I get this error:</p>
  
  <pre><code>TypeError: Cannot read property 'headers' of undefined
  </code></pre>
  
  <p>Is there any solution for this problem or use another method? </p>
  
  <p>I need digest auth for the whole application.</p>