From 3405f9f515b0cd1c41a61cddb0034e2fe91d26b7 Mon Sep 17 00:00:00 2001 From: devsargam Date: Sun, 31 Mar 2024 21:24:14 +0530 Subject: [PATCH] fix(dev): improve local development experience --- src/lib/auth.ts | 10 ++++++++++ src/middleware.ts | 2 ++ 2 files changed, 12 insertions(+) diff --git a/src/lib/auth.ts b/src/lib/auth.ts index 11c1c7845..e84ffd331 100644 --- a/src/lib/auth.ts +++ b/src/lib/auth.ts @@ -91,6 +91,16 @@ export const authOptions = { }, async authorize(credentials: any) { try { + if (process.env.LOCAL_CMS_PROVIDER) { + return { + id: '1', + name: 'test', + email: 'test@gmail.com', + token: await generateJWT({ + id: 1, + }), + }; + } const hashedPassword = await bcrypt.hash(credentials.password, 10); const userDb = await prisma.user.findFirst({ diff --git a/src/middleware.ts b/src/middleware.ts index 605cbcea6..8f8d4d953 100644 --- a/src/middleware.ts +++ b/src/middleware.ts @@ -6,6 +6,8 @@ export const config = { }; export default withAuth(async (req) => { + if (process.env.LOCAL_CMS_PROVIDER) return; + const token = req.nextauth.token; if (!token) { return NextResponse.redirect(new URL('/invalidsession', req.url));