refactor(env): centralize auth env handling and prefer BETTER_AUTH_BASE_URL

This commit is contained in:
2026-01-24 10:10:00 +00:00
parent dc324b03a3
commit a9cb97727d
4 changed files with 40 additions and 8 deletions

View File

@@ -3,6 +3,7 @@ import { drizzleAdapter } from 'better-auth/adapters/drizzle';
import { db } from './db/client';
import { schema } from './db/schema';
import { getBetterAuthBaseUrl, getRequiredEnv } from './utils/env';
import { hashPassword, verifyPassword } from './utils/password';
const trustedOrigins = process.env.BETTER_AUTH_TRUSTED_ORIGINS
@@ -24,8 +25,8 @@ export const auth = betterAuth({
verify: async ({ hash, password }) => verifyPassword(password, hash),
},
},
secret: process.env.BETTER_AUTH_SECRET,
baseURL: process.env.BETTER_AUTH_URL,
secret: getRequiredEnv('BETTER_AUTH_SECRET'),
baseURL: getBetterAuthBaseUrl(),
trustedOrigins,
});