change branch to Akbar-antren

This commit is contained in:
Fanrouver
2025-10-13 09:25:44 +07:00
parent 51809468a9
commit 0351f9116d
18 changed files with 3698 additions and 4827 deletions

View File

@@ -1,48 +1,3 @@
// export default defineNuxtRouteMiddleware(async (to) => {
// console.log('🛡️ Auth middleware triggered for:', to.path)
// // Skip middleware on server-side during build/generation
// if (process.server && process.env.NODE_ENV === 'development') {
// console.log('⏭️ Skipping auth check on server-side during development')
// return
// }
// // Allow the login page to handle its own checks
// if (to.path === '/LoginPage') {
// console.log('⏭️ Allowing access to LoginPage')
// return
// }
// // This is the crucial change: check for the authentication signal
// const isAuthRedirect = to.query.authenticated === 'true';
// // If this is a redirect from a successful login, we need to let the route load
// if (isAuthRedirect) {
// console.log('⏳ Client-side is processing a new login session, allowing the route to load...');
// // We navigate to a clean URL to remove the query parameter
// return navigateTo({ path: to.path, query: {} }, { replace: true });
// }
// try {
// console.log('🔍 Checking authentication status...')
// const session = await $fetch<{ user: any } | null>('/api/auth/session').catch(() => null)
// if (session && session.user) {
// console.log('✅ User is authenticated:', session.user.name || session.user.email)
// return
// } else {
// console.log('❌ No valid session found, redirecting to login')
// return navigateTo('/LoginPage')
// }
// } catch (error) {
// console.error('❌ Auth middleware error:', error)
// console.log('🔄 Redirecting to login due to error')
// return navigateTo('/LoginPage')
// }
// })
import { defineNuxtRouteMiddleware, navigateTo } from '#app';
import type { RouteLocationNormalized } from 'vue-router';