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 “to.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 :
<script setup lang="ts">
definePageMeta({
myMid : false
});
</script>
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 :
<script setup lang="ts">
definePageMeta({
middleware : ["myMid"]
});
</script>
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.