appMiddleware for API routes?
When an API under /api/admin is being called I want to run my middleware under /server/middleware/admin.ts
I thought I could add a route rule to the nuxt.config.ts like this:
But still, the middleware runs on every request which is also mentioned in the docs (https://nuxt.com/docs/guide/directory-structure/server#server-middleware)
But I was wondering if something like this
'/api/admin/**': { appMiddleware: 'admin' }
is possible?
Otherwise I would need to do something like if (requestUrl.includes('/api/admin'))
right?Nuxt
server/ · Nuxt Directory Structure
The server/ directory is used to register API and server handlers to your application.
0 Replies