ServerAuth
Configuration
Better Auth setup, plugins, and configuration options.
Auth Instance
The auth instance is configured in packages/crm/auth/src/index.ts:
import { betterAuth } from "better-auth";
export const auth = betterAuth({
database: prismaAdapter(basePrisma, {
provider: "postgresql",
}),
session: {
cookieCache: {
enabled: true,
maxAge: 5 * 60,
},
},
plugins: [
organization(),
admin(),
apiKey(),
oneTap(),
],
});Plugins
| Plugin | Purpose |
|---|---|
organization | Multi-tenant organization support |
admin | Admin role capabilities |
apiKey | API key authentication |
oneTap | Google One Tap login |
Configuration Options
Session Configuration
session: {
cookieCache: {
enabled: true,
maxAge: 5 * 60, // 5 minutes
},
expiresIn: 60 * 60 * 24 * 7, // 7 days
updateAge: 60 * 60 * 24, // 1 day
}Cookie Configuration
cookies: {
domain: ".crm.selegic.com", // Production
secure: true,
sameSite: "none",
}Trusted Origins
trustedOrigins: [
"https://crm.selegic.com",
"http://localhost:3000",
]Environment Variables
BETTER_AUTH_URL=https://crm.selegic.com
CORS_ORIGIN=https://crm.selegic.com
GOOGLE_CLIENT_ID=...
GOOGLE_CLIENT_SECRET=...