Detect IE in expressjs, but can't get static files

I've tried to detect IE by using expressjs, the code surely redirect me to the error page.

But the problem is that it won't render css files and get image files in my folder.

I think the problem is that expressjs redirect to error_page before the static path is set.

So I put app.all('*', ieRedirecter);, after

app.use(express.static(path.join(__dirname, 'public')));
app.use(express.static(__dirname + '/uploads'));

The problem is still occur... could someone help me out, thanks!

My settings

function ieRedirecter(req, res, next) {
  if(req.headers['user-agent'].indexOf("MSIE") >= 0) {
    var myNav = req.headers['user-agent'];
    var IEbrowser = parseInt(myNav.split('MSIE')[1]) 
    if(IEbrowser < 9) {
      res.render('error/browser_error', {title : 'not supporting your browser'})
    } else {
      next();
    }
  } else {
    next();
  }
};

app.configure(function(){
    app.set('port', process.env.PORT || 3000);
    ...
    ...
    ...
    app.use(app.router);

    app.use(express.static(path.join(__dirname, 'public')));
    app.use(express.static(__dirname + '/uploads'));

    app.all('*', ieRedirecter);
})

This order doesn't work:

app.use(app.router);

app.use(express.static(path.join(__dirname, 'public')));
app.use(express.static(__dirname + '/uploads'));

app.all('*', ieRedirecter);

app.router is the middleware that handles all your routing requests, including app.all(), even though you declare that route after your other middleware (fun fact: at any moment you declare a route – using app.{get,post,all,...} – the app.router middleware is inserted into the middleware chain automatically).

If possible, the easiest solution would be to move the static and IE middleware to before your routes (but I realize that might cause problems with your application setup):

// static middleware first...
app.use(express.static(path.join(__dirname, 'public')));
app.use(express.static(__dirname + '/uploads'))

// ...followed by the IE check
app.use(ieRedirecter);

// ...followed by your routes
app.get('/', ...);
...

Another solution would be filter out requests for static resources in your ieRedirecter middleware by looking at req.path, but that assumes that you can easily identify those requests (like if they start with /css or /js).