Closed ghoshRitesh12 closed 1 year ago
Hi. Thanks for opening issue and explaining but Nuxt middleware are Powered by Vue router and completely different than Nitro/Server middleware.
Generally, I would recommend you prefer server/utils
to make composables used in each handler instead of global server middleware.
You can also have an if condition in server middleware to filter them out based on event.path
or event.method
(which I still won't recommend again unless necessary).
Also, you can use new h3 handler object syntax to set multiple middleware per route (https://unjs.io/blog/2023-08-15-h3-towards-the-edge-of-the-web#object-syntax-event-handlers)
Describe the feature
In Nuxt, I have 2 middlewares in
/middlewares
dir, namely native and admin and I can use them using thedefinePageMeta()
macro in the pages that I prefer. I have a refined control over the client middlewares and which pages I want them to be in.It would be great to have this refined control for server middlewares as well. In
/server/middlewares
, I should be able to define middlewares and use them for specific server routes and NOT for all server routes, which is the default behavior. I should also be able to chain middlewares, much like in the client side.Additional information