From 97f00aa7a1dd9d9eaf1e3f12475868062974ec3a Mon Sep 17 00:00:00 2001 From: Emir Karabeg Date: Fri, 25 Apr 2025 13:15:31 -0700 Subject: [PATCH] fix: Stripe error hidden for local dev --- sim/lib/auth.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/sim/lib/auth.ts b/sim/lib/auth.ts index 3eecc89445..9a8a97264b 100644 --- a/sim/lib/auth.ts +++ b/sim/lib/auth.ts @@ -19,9 +19,18 @@ const logger = createLogger('Auth') const isProd = process.env.NODE_ENV === 'production' -const stripeClient = new Stripe(process.env.STRIPE_SECRET_KEY || '', { - apiVersion: "2025-02-24.acacia", -}) +// Only initialize Stripe if the key is provided +// This allows local development without a Stripe account +const validStripeKey = process.env.STRIPE_SECRET_KEY && process.env.STRIPE_SECRET_KEY.trim() !== '' && process.env.STRIPE_SECRET_KEY !== 'placeholder' + +let stripeClient = null +if (validStripeKey) { + stripeClient = new Stripe(process.env.STRIPE_SECRET_KEY || '', { + apiVersion: "2025-02-24.acacia", + }) +} else { + logger.warn('No valid Stripe secret key found.') +} // 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