diff --git a/packages/ui/.env.example b/packages/ui/.env.example index 004c5c34..d43b8bdc 100644 --- a/packages/ui/.env.example +++ b/packages/ui/.env.example @@ -3,7 +3,7 @@ LANGTRACE_API_URL=http://localhost:1984 # Auth NEXTAUTH_ENABLE=false -NEXTAUTH_URL=http://localhost:3000 +#NEXTAUTH_URL=http://localhost:3000 #NEXTAUTH_SECRET= ## Github diff --git a/packages/ui/src/app/api/auth/[...nextauth]/route.ts b/packages/ui/src/app/api/auth/[...nextauth]/route.ts index 3ea5f262..edb19b5d 100644 --- a/packages/ui/src/app/api/auth/[...nextauth]/route.ts +++ b/packages/ui/src/app/api/auth/[...nextauth]/route.ts @@ -1,5 +1,12 @@ import { authOptions } from '@/lib/utils/auth-options'; import NextAuth from 'next-auth'; +import { NextApiRequest, NextApiResponse } from 'next'; -const handler = NextAuth(authOptions); +const handler = (req: NextApiRequest, res: NextApiResponse) => { + if (process.env.NEXTAUTH_ENABLE === 'false') { + console.warn('NextAuth is disabled'); + return res.status(200).json({ message: 'NextAuth is disabled' }); + } + return NextAuth(req, res, authOptions); +}; export { handler as GET, handler as POST }; diff --git a/packages/ui/src/app/page.tsx b/packages/ui/src/app/page.tsx index 9df2b5db..1849dc7e 100644 --- a/packages/ui/src/app/page.tsx +++ b/packages/ui/src/app/page.tsx @@ -28,7 +28,7 @@ export const metadata = { export default async function Home() { const session = await getServerSession(authOptions); - if (session) { + if (session || process.env.NEXTAUTH_ENABLE !== 'true') { return <>