Pages

30 April, 2024

disable global middleware from some pages - nuxt 3

When you set the middleware as global, and let's say myMid.global.ts, there are some pages on which I do not want this middleware to work. I searched and found a way using route name, and I want a better way. For example, on the page where I do not want it to work, I put, for example:


some-ex-page.vue :


definePageMeta({
myMid : false
});





Or anything else. Most pages need this middleware, but there are pages that do not. I do not think it is a good idea to go through all of these pages and manually enter the name of the middleware:


some-ex-page.vue :


definePageMeta({
middleware : ["myMid"]
});





Or, for example, there is a way to add a new property to the page. In the middleware, I can check that if this property exists, I will avoid working from this page.

No comments:

Post a Comment

Thanks