I want to password protect specific routes and would like to add a meta data to every route like this:
{
path: '/route-path',
name: 'route-name',
component: ComponentName,
meta: {
requiresAuth: true
}
}
So I can check this in
router.beforeEach((to, from, next)
I have access to router.beforeEach in main.js but where do I add the auth flag to each route? gridsome.config.js does not seem to work?
Although it's not currently documented you can use the create page API and pass it a
route
property, for example...src/pages.js
gridsome.server.js
I also moved the page components into a
src/views
directory to avoid route auto generation.