fix(auth): add trustedOrigins to BetterAuth for cross-origin web dashboard #111

Merged
jason.woltje merged 1 commits from fix/betterauth-cors into main 2026-03-15 16:44:21 +00:00

View File

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