Symfony 8 + API Platform 4 + Nuxt 4 monorepo. Backend: User entity, JWT auth, fixtures. Frontend: login, dashboard, auth middleware, i18n, @malio/layer-ui. Docker: dev (ports 8083/3003/5436) + prod multi-stage. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
17 lines
369 B
TypeScript
17 lines
369 B
TypeScript
export default defineNuxtRouteMiddleware(async (to) => {
|
|
const auth = useAuthStore()
|
|
const isLogin = to.path === '/login'
|
|
|
|
if (!auth.checked) {
|
|
await auth.ensureSession()
|
|
}
|
|
|
|
if (!isLogin && !auth.isAuthenticated) {
|
|
return navigateTo('/login')
|
|
}
|
|
|
|
if (isLogin && auth.isAuthenticated) {
|
|
return navigateTo('/')
|
|
}
|
|
})
|