diff --git a/app/api/auth/[...nextauth]/route.ts b/app/api/auth/[...nextauth]/route.ts index c54aea2..182d5b6 100644 --- a/app/api/auth/[...nextauth]/route.ts +++ b/app/api/auth/[...nextauth]/route.ts @@ -61,6 +61,9 @@ export const authOptions: NextAuthOptions = { callbacks: { async jwt({ token, account, profile }) { if (account && profile) { + if (!account.access_token || !account.refresh_token) { + throw new Error('Missing required token fields from Keycloak'); + } token.accessToken = account.access_token; token.refreshToken = account.refresh_token; token.accessTokenExpires = account.expires_at! * 1000; diff --git a/app/layout.tsx b/app/layout.tsx index 1da0682..5082627 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -3,7 +3,7 @@ import { Inter } from "next/font/google"; import "./globals.css"; import { headers } from "next/headers"; import { getServerSession } from "next-auth/next"; -import { authOptions } from "@/lib/auth"; +import { authOptions } from "@/app/api/auth/[...nextauth]/route"; import { Providers } from "@/components/providers"; import { LayoutWrapper } from "@/components/layout/layout-wrapper"; import { Toaster } from "@/components/ui/toaster";