appMiddleware in routeRules not working?
I want to run a middleware when my API in
/server/api/admin/text-snippet.post.ts
is being called but it doesn't run the middleware at all.
Nuxt 3.12.2
nuxt.config.ts
middleware/mytest.ts
server/api/admin/text-snippet.post.ts
Then, I access the API via Postman. Method: Post. URL: http://localhost:3000/api/admin/text-snippet
The response is { success: true }
What am I missing or is this a bug?2 Replies
Thank you so much! I moved it into server/middleware and now it's being executed đ
And then if the user is for example not authorized I'd do something like this?
Alrightâbut it does the job in my case. Thank you!
I was looking 2 hours for a solutionââthank you đ
how do u do that?
how do u make a wrapper for defineEventHandler
and where would u define it? in server/utils?