title: Expressjs not recognizing static files
body: <p>I have a nodejs app and am using expressjs. I've defined my static directory, but when I access it, it doesn't load.  My express config is:</p>
  
  <pre><code>var app = express.createServer().listen(8001);
  app.configure(function(){
        app.use(express.methodOverride());
        app.use(express.bodyParser());
        app.use(app.router);
        app.use('/public', express.static(__dirname + '/public'));
        app.use(express.cookieParser());
        app.use(express.session({ secret: "appsession" }));
        app.use(express.errorHandler({showStack: true, dumpExceptions: true}));
        app.set('views', __dirname + '/views');
        app.set('view engine', 'hbs');
  });
  </code></pre>
  
  <p>Inside my <code>/public</code> directory I have 3 folders, css, js, and img.  Inside css I have a style.css.  When I try to access it directly via <a href="http://localhost:8001/public/css/style.css" rel="nofollow">http://localhost:8001/public/css/style.css</a> I get: <code>Cannot GET /public/css/style.css</code></p>
  
  <p>Any ideas what I could be doing wrong?</p>
  
  <p>Thanks!</p>
  
  <p>EDIT:</p>
  
  <p>It seems to be related to how I have my routes setup.  I'm doing it like this:</p>
  
  <pre><code>     var routes = require('./routes')(db);
       pp.get('/', routes.index);
  </code></pre>
  
  <p>Then in my <code>index.js</code> file, I have:</p>
  
  <pre><code>module.exports = function(db) {
      return {
  
          index: function(req, res, next) { 
                  res.render('index');
              }
           }
       }
  </code></pre>
  
  <p>I have my error handling enabled, but when I use the routing in this way, it doesn't use expresses error handling, however if I take this out, it does.</p>