import type { NextAuthConfig } from 'next-auth'; export const authConfig = { pages: { signIn: '/login', }, callbacks: { authorized({ auth, request: { nextUrl } }) { const isLoggedIn = !!auth?.user; const isOnLogin = nextUrl.pathname.startsWith('/login'); const isPublicPath = nextUrl.pathname === '/' || nextUrl.pathname.startsWith('/api') || isOnLogin; if (isOnLogin) { if (isLoggedIn) return Response.redirect(new URL('/dashboard', nextUrl)); return true; } if (!isLoggedIn && !isPublicPath) { return false; // Redirect unauthenticated users to login page } return true; }, }, providers: [], // Add providers with an empty array for now } satisfies NextAuthConfig;