Middleware runs only on the client side for server components in case of client routing
Hi all, I have this setup: https://stackblitz.com/edit/github-ov7xof?file=pages%2Fadmin%2Findex.server.vue
Could you help me identify the issues, so it'll work the way I'd like it to work?
My goal is to only authorise admins to be able to reach the admin page, in the example I made it impossible for anyone, so it is easier to demonstrate my problem.
On the index/landing page if I navigate to the admin page(I press the 'to the admins' button), the admin page will load, but if I refresh the page i get a 401 error as I should. In the middleware I have a line that makes the middleware not run on the client side.
So I think my middleware doesn't run on the server side, when it is client side routing, although the admin page is a server side component and will always render with SSR. But it does when it is the initially loaded page. So I assume even if that line is not present in the middleware that makes it not run on client side, it would not run when the admin page is rendered on the server side. Is this what is happening?
Could you help me make the middleware run in serverside or give me suggestions how I can enforce similar behaviour where I can control what html code I give away?
kovacsvolgyid
StackBlitz
Nuxt - Starter - StackBlitz
Create a new Nuxt project, module, layer or start from a theme with our collection of starters.
0 Replies