feat[auth]: when no resend key is provided for emails, log instead

This commit is contained in:
Waleed Latif
2025-03-17 17:13:18 -07:00
parent ac6f284c42
commit aa960afad8
2 changed files with 10 additions and 8 deletions

View File

@@ -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

View File

@@ -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, {