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