diff --git a/app/api/auth/[...nextauth]/route.ts b/app/api/auth/[...nextauth]/route.ts index 4ff56ed4..3d6d16f0 100644 --- a/app/api/auth/[...nextauth]/route.ts +++ b/app/api/auth/[...nextauth]/route.ts @@ -59,6 +59,10 @@ export const authOptions: NextAuthOptions = { }, }), ], + session: { + strategy: "jwt", + maxAge: 30 * 24 * 60 * 60, // 30 days + }, callbacks: { async jwt({ token, account, profile }) { // Log only non-sensitive information @@ -128,7 +132,6 @@ export const authOptions: NextAuthOptions = { }; } }, - async session({ session, token }) { console.log("Session callback - processing session for user:", token.sub); @@ -153,7 +156,7 @@ export const authOptions: NextAuthOptions = { session.rocketChatUserId = token.rocketChatUserId || null; return session; - }, + } }, events: { async signOut({ token }) { @@ -180,7 +183,11 @@ export const authOptions: NextAuthOptions = { } }, }, - debug: process.env.NODE_ENV === 'development', // Only enable debug logging in development + pages: { + signIn: '/signin', + error: '/signin', + }, + debug: process.env.NODE_ENV === 'development', }; const handler = NextAuth(authOptions); diff --git a/app/api/emails/route.ts b/app/api/emails/route.ts index 21c86b07..8f26747e 100644 --- a/app/api/emails/route.ts +++ b/app/api/emails/route.ts @@ -23,7 +23,7 @@ export async function GET(req: NextRequest) { } // First, get a Nextcloud OIDC token using client credentials - const tokenResponse = await fetch(`${nextcloudUrl}/index.php/apps/oauth2/api/v1/token`, { + const tokenResponse = await fetch(`${nextcloudUrl}/apps/oauth2/api/v1/token`, { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded', @@ -36,9 +36,11 @@ export async function GET(req: NextRequest) { }); if (!tokenResponse.ok) { + const errorData = await tokenResponse.json(); console.error('Failed to get Nextcloud token:', { status: tokenResponse.status, statusText: tokenResponse.statusText, + error: errorData }); return NextResponse.json({ error: 'Nextcloud authentication failed' }, { status: 401 }); }