Middlewares no longer work.

Since we upgraded from 3.11.2 to 3.12.4 middlewares are no longer loading up.
definePageMeta({
  middleware: 'auth',
})

Is there a new way to implement this?

file is middleware/auth.ts

import { Routes } from '~/enums/Routes'
import QueryEnum from '~/enums/QueryEnum'
import getLocalizedRoute from '~/utils/getLocalizedRoute'

export default defineNuxtRouteMiddleware(async (_to, from) => {
  const loggedIn = await useCurrentUser().isLoggedIn()

  if (!loggedIn) {
    return navigateTo(
      getLocalizedRoute(
        Routes.Login,
        {},
        {
          [QueryEnum.Redirect]: from.fullPath,
        }
      )
    )
  }
})
Was this page helpful?