I am currently writing an API which will require a user to pass an authentication token in the header of each request. Now I know I can create a catchall route say
You can always place catch-all route after the ones you want to exclude (see robertklep answer).
But sometimes you simply don't want to care about the order of your routes. In this case you still can do what you want:
app.get('*', function(req, res, next) {
if (req.url === '/' || req.url === '/login') return next();
...
});