Search⌘ K

Fallback Routes

Explore how to implement fallback routes in Nuxt 3's server API by creating generic catch-all handlers and specific route fallbacks. Understand how to respond to unmatched requests with tailored messages, improving your server's route handling capabilities.

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:

The catch all route file
The catch all route file

The contents of this file can be anything we ...