SSG with Fallback
A middleware is a special function that gets executed before a route.
You can create a middleware in the middleware folder:
// middleware/sample-middleware.js
export default defineNuxtRouteMiddleware((to, from) => {
// your middleware code
})
You can return either abortNavigation()
or navigateTo(path)
inside the middleware.
Then in the component, you have to register the middleware:
definePageMeta({
middleware: [
'sample-middleware'
]
})