Questions & Answers

What is the difference between global middleware and per-route middleware?

Deepkit HTTP
50 up-votes
Warning: The answer is generated by an artificial intelligence. It might not be correct.
To adjust rating, open the thread in Discord and click on the up/down vote button.

Global middleware is applied to all routes in your application, while per-route middleware is applied only to specific routes.

Global middleware is registered using the middlewares option in the App configuration, while per-route middleware is added using the middleware decorator at the controller or action level.

Global middleware is useful for applying common functionality to all routes, such as authentication or logging. Per-route middleware allows you to apply specialized functionality to specific routes.