From 6c35293e80dc3e9936f9225ca81b8c9109a67c33 Mon Sep 17 00:00:00 2001 From: lucas-neynar Date: Thu, 10 Apr 2025 10:56:48 -0700 Subject: [PATCH] feat: add more logging for error debugging --- scripts/dev.js | 2 +- src/auth.ts | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/scripts/dev.js b/scripts/dev.js index d125545..c1f9a00 100755 --- a/scripts/dev.js +++ b/scripts/dev.js @@ -9,7 +9,7 @@ import { fileURLToPath } from 'url'; dotenv.config({ path: '.env.local' }); const __dirname = path.dirname(fileURLToPath(import.meta.url)); -const projectRoot = path.join(__dirname, '..'); +const projectRoot = path.resolve(path.normalize(path.join(__dirname, '..'))); let tunnel; let nextDev; diff --git a/src/auth.ts b/src/auth.ts index cf3a653..8c39468 100644 --- a/src/auth.ts +++ b/src/auth.ts @@ -58,6 +58,11 @@ export const authOptions: AuthOptions = { }, async authorize(credentials, req) { const csrfToken = req?.body?.csrfToken; + if (!csrfToken) { + console.error('CSRF token is missing from request'); + return null; + } + const appClient = createAppClient({ ethereum: viemConnector(), }); @@ -120,4 +125,11 @@ export const authOptions: AuthOptions = { } } -export const getSession = () => getServerSession(authOptions) +export const getSession = async () => { + try { + return await getServerSession(authOptions); + } catch (error) { + console.error('Error getting server session:', error); + return null; + } +}