Can we use the middlewares based on the file system structure? For example i want to run admin.ts middleware for all the pages inside pages/admin, and another middleware normaluser.ts for other directories inside the pages folder. Do i have to go and write one by one for each page to use that middleware or is there simpler way to accomplish this?
This is my first Vue project so many thanks for this content, it helps a great deal. Note that if you return nothing then it goes to the next middleware function or competes the route so my 'auth.global.ts' looks like this: export default defineNuxtRouteMiddleware((to, from) => { const isAuthenticated = false; if (!isAuthenticated && to.path !== "/login") { return navigateTo("/login"); } });
muchas gracias, excelente contenido 👌👌👌👌👌👌👌👌
supper... continue, your are doing a very good work. thank you man...
Can we use the middlewares based on the file system structure? For example i want to run admin.ts middleware for all the pages inside pages/admin, and another middleware normaluser.ts for other directories inside the pages folder. Do i have to go and write one by one for each page to use that middleware or is there simpler way to accomplish this?
Hello! If I do 'auth', where I need do 'middleware'? In Server/middleware folder? Thanks you for Vue/Nuxt videos!
Dépends on what you want to do
Thank you man! You are me very helped)
No problem my friend enjoy
Can i add middleware to a component? Example comment component, if the user not loged in the user will redirect to login
Better do it to a page
This is my first Vue project so many thanks for this content, it helps a great deal.
Note that if you return nothing then it goes to the next middleware function or competes the route so my 'auth.global.ts' looks like this:
export default defineNuxtRouteMiddleware((to, from) => {
const isAuthenticated = false;
if (!isAuthenticated && to.path !== "/login") {
return navigateTo("/login");
}
});
light!!!!
tq bro ...
First!
Türk müsün la