Selegic CRM Docs
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

PluginPurpose
organizationMulti-tenant organization support
adminAdmin role capabilities
apiKeyAPI key authentication
oneTapGoogle 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
}
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=...

On this page