Skip to content Skip to sidebar Skip to footer

Expressjs Bind All Routes Except 2 Folders?

In expressjs, how do I bind a route to all urls except /static and /fail For example, it sound bind to: /users /books /books/anything but not bind to /static /fail /fail/anything

Solution 1:

If you are saying you want to create one route for everything but /static* then here is the command for creating the GET route:

app.get(/^((?!\/static).)*$/, function(req, res){

    //Do your thing in here...
});

Post a Comment for "Expressjs Bind All Routes Except 2 Folders?"