I am currently developing a Nuxt TypeScript project. My middleware is located in /middleware/redirect.ts:
import { Middleware } from '@nuxt/types'
const redirectMiddleware: Middleware = (context) => {
console.log(context)
}
export default redirectMiddleware
I have added the middleware to my index.vue page like this:
<script lang="ts">
import Vue from 'vue'
import redirectMiddleware from '~/middleware/redirect'
export default Vue.extend({
middleware: [redirectMiddleware],
data () {
return {}
}
})
</script>
However, the middleware does not seem to work and I am getting an error. Can anyone help with a solution?
It seems that the documentation provided is unclear. Click here for more information.