From 9609a15534c4c0f19c0204ec4bb6d4d2231f905e Mon Sep 17 00:00:00 2001 From: David Gwilliam Date: Tue, 31 Mar 2026 09:01:33 -0700 Subject: [PATCH] fix: configure Better Auth for euchre.notsosm.art domain --- src/lib/auth.ts | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/src/lib/auth.ts b/src/lib/auth.ts index a4f7a64..f49f611 100644 --- a/src/lib/auth.ts +++ b/src/lib/auth.ts @@ -15,10 +15,39 @@ export const auth = betterAuth({ autoSignIn: true, // Automatically sign in after registration requireEmailVerification: false, // Don't require email verification for tests }, - secret: process.env.BETTER_AUTH_SECRET, - baseURL: process.env.BETTER_AUTH_URL || "http://localhost:3000", - // Disable trusted origins validation - trustedOrigins: [], + secret: process.env.BETTER_AUTH_SECRET || process.env.NEXTAUTH_SECRET, + baseURL: process.env.BETTER_AUTH_URL || process.env.NEXTAUTH_URL || "http://localhost:3000", + // Configure trusted origins - parse from environment or use defaults + trustedOrigins: (() => { + const origins = []; + + // Add environment-specified origins + if (process.env.TRUSTED_ORIGINS) { + origins.push(...process.env.TRUSTED_ORIGINS.split(',').map(o => o.trim())); + } + + // Add BETTER_AUTH_URL if set + if (process.env.BETTER_AUTH_URL) { + origins.push(process.env.BETTER_AUTH_URL); + } + + // Add NEXTAUTH_URL if set + if (process.env.NEXTAUTH_URL) { + origins.push(process.env.NEXTAUTH_URL); + } + + // Add defaults + origins.push( + "https://euchre.notsosm.art", + "http://euchre.notsosm.art", + "http://localhost:3000", + "http://127.0.0.1:3000", + "http://0.0.0.0:3000" + ); + + // Remove duplicates and empty strings + return [...new Set(origins.filter(o => o))]; + })(), session: { cookieCache: { enabled: false, // Disable cookie cache to avoid session cache issues