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
I'm not sure what you want to happen when a user accesses /login or /, but you can create separate routes for those; if you declare them before the catch-all, they get first dibs at handling the incoming requests:
app.get('/login', function(req, res) {
...
});
app.get('/', function(req, res) {
...
});
app.get('*', function(req, res) {
...
});