How to assign a middleware to custom routes?

So for file-system based routing you assign middleware to individual pages or a parent page through definePageMeta utility function. But, as definePageMeta is ignored in custom routing, how do you assign a middleware in this case. I have gone through the documentation but couldn't find any clean solutions. I think you should be able to assign middleware to routes in router.options.js file like this:
{
    path: "account",
    name: "account",
    middleware: "auth",
    component: account
}

But this doesn't work. Do you have any better solution for this?
Was this page helpful?