Fallback Routes

Learn how to handle responses to unrecognized server routes.

We can handle how the server will respond if a request is made that does not match any route handler. This can be either a generic, catch-all handler or a more specific handler for particular routes.

Catching all routes

A catch-all file can be added to our server routes as a generic fallback if no matching handler is found. We can add this to the root of our server/api directory in a file named [...].js:

Get hands-on with 1400+ tech skills courses.