From 014ebdacda02f87c204fceeadaf2e726737d32f5 Mon Sep 17 00:00:00 2001 From: Jason Woltje Date: Sun, 15 Mar 2026 16:44:20 +0000 Subject: [PATCH] fix(auth): add trustedOrigins to BetterAuth for cross-origin web dashboard (#111) Co-authored-by: Jason Woltje Co-committed-by: Jason Woltje --- packages/auth/src/auth.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/auth/src/auth.ts b/packages/auth/src/auth.ts index ea473a9..329039e 100644 --- a/packages/auth/src/auth.ts +++ b/packages/auth/src/auth.ts @@ -39,6 +39,9 @@ export function createAuth(config: AuthConfig) { ] : undefined; + const corsOrigin = process.env['GATEWAY_CORS_ORIGIN'] ?? 'http://localhost:3000'; + const trustedOrigins = corsOrigin.split(',').map((o) => o.trim()); + return betterAuth({ database: drizzleAdapter(db, { provider: 'pg', @@ -47,6 +50,7 @@ export function createAuth(config: AuthConfig) { baseURL: baseURL ?? process.env['BETTER_AUTH_URL'] ?? 'http://localhost:4000', secret: secret ?? process.env['BETTER_AUTH_SECRET'], basePath: '/api/auth', + trustedOrigins, emailAndPassword: { enabled: true, },