Server middleware for specific route
Hi, i have this structure:
- /pages/page/[...slug].vue
- /pages/component/[...slug].vue
And i want to make server middleware only for these routes, how can i do this?
I was trying with this solution:
- /server/routes/page/[...slug].get.ts
- /server/routes/page/[...slug].post.ts
but it's nor working. Can you help me?
2 Replies
well, server middlewares should be in server/middleware folder, aside from that you can easily do something like this:
https://nuxt.com/docs/guide/directory-structure/server#server-middleware
also if i understand correctly you have vue components inside your pages folder. you should move them out of the pages folder and into components folder
No, no, 'component' is just a page 🙂 Thanks for your help!