Using Nuxt-Auth, is there an official way to check if a route is protected (ie requires login)?
In some sample middleware, doing a console log of "route" shows a large JSON payload with some mentions of middleware: 'auth'
. However how reliable is this method? What if the JSON structure changes in the future?
export default function({ $auth, route }) {
// This returns 'auth' for protected routes; undefined for unprotected routes.
// But how reliable is this method? The JSON structure could change in the future.
console.log(route.matched[0].components.default.options.middleware)
}