Middlewares no longer work.

Since we upgraded from 3.11.2 to 3.12.4 middlewares are no longer loading up.
definePageMeta({
middleware: 'auth',
})
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,
}
)
)
}
})
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,
}
)
)
}
})
3 Replies
Denis Jankelaic
Denis JankelaicOP4mo ago
bump.
oneeach
oneeach4mo ago
what is the returned value of useCurrentUser().isLoggedIn()?
Denis Jankelaic
Denis JankelaicOP4mo ago
true/false, but the problem is the middleware is not called at all.
Want results from more Discord servers?
Add your server