From aa960afad8e86d9c9ae9d56b5145e59c39164724 Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Mon, 17 Mar 2025 17:13:18 -0700 Subject: [PATCH] feat[auth]: when no resend key is provided for emails, log instead --- sim/.env.example | 3 ++- sim/app/lib/auth.ts | 15 ++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/sim/.env.example b/sim/.env.example index 5a6375afa4..3a340f1e55 100644 --- a/sim/.env.example +++ b/sim/.env.example @@ -6,7 +6,8 @@ BETTER_AUTH_SECRET=your_secret_key # Use `openssl rand -hex 32` to generate, or BETTER_AUTH_URL=http://localhost:3000 # Email Provider (Optional) -RESEND_API_KEY=your_resend_api_key # Get from https://resend.com +# RESEND_API_KEY= # Uncomment and add your key from https://resend.com to send actual emails + # If left commented out, emails will be logged to console instead # App URL (Required) NEXT_PUBLIC_APP_URL=http://localhost:3000 diff --git a/sim/app/lib/auth.ts b/sim/app/lib/auth.ts index 08a7d439ef..cf7871e4c5 100644 --- a/sim/app/lib/auth.ts +++ b/sim/app/lib/auth.ts @@ -12,13 +12,14 @@ const logger = createLogger('Auth') // If there is no resend key, it might be a local dev environment // In that case, we don't want to send emails and just log them -const resend = process.env.RESEND_API_KEY - ? new Resend(process.env.RESEND_API_KEY) - : { - emails: { - send: async (...args: any[]) => logger.info('Email sent:', args), - }, - } +const resend = + process.env.RESEND_API_KEY && process.env.RESEND_API_KEY.trim() !== '' + ? new Resend(process.env.RESEND_API_KEY) + : { + emails: { + send: async (...args: any[]) => logger.info('Email sent:', args), + }, + } export const auth = betterAuth({ database: drizzleAdapter(db, {