fix: keep session middleware from redirecting prematurely
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { useProfileSession } from '#imports'
|
||||
|
||||
export default defineNuxtRouteMiddleware(async (to) => {
|
||||
const { ensureSession, activeProfile } = useProfileSession()
|
||||
const { ensureSession, fetchCurrentProfile, activeProfile } = useProfileSession()
|
||||
await ensureSession()
|
||||
|
||||
const rawPath = to?.path ?? ''
|
||||
@@ -13,6 +13,10 @@ export default defineNuxtRouteMiddleware(async (to) => {
|
||||
fullPath.startsWith('/profiles') ||
|
||||
routeName.startsWith('profiles')
|
||||
|
||||
if (process.client && !activeProfile.value) {
|
||||
await fetchCurrentProfile()
|
||||
}
|
||||
|
||||
if (process.client && !activeProfile.value && !isProfilesRoute) {
|
||||
return navigateTo('/profiles')
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user