31 lines
1.0 KiB
TypeScript
31 lines
1.0 KiB
TypeScript
import { drizzleAdapter } from "@better-auth/drizzle-adapter/relations-v2";
|
|
import { db } from "../server/lib/db";
|
|
import { betterAuth } from 'better-auth/minimal';
|
|
import * as schema from '../drizzle/schema';
|
|
|
|
export const auth = betterAuth({
|
|
database: drizzleAdapter(db, {
|
|
provider: "pg",
|
|
schema,
|
|
usePlural: true,
|
|
}),
|
|
|
|
session: {
|
|
expiresIn: 60 * 60 * 24 * 30, // 1 month
|
|
updateAge: 60 * 60 * 24 * 1, // 1 day
|
|
cookieCache: {
|
|
enabled: true,
|
|
maxAge: 5 * 60,
|
|
},
|
|
},
|
|
|
|
baseURL: process.env.NUXT_PUBLIC_URL ?? 'http://localhost:3000',
|
|
trustedOrigins: [process.env.NUXT_PUBLIC_URL ?? 'http://localhost:3000'],
|
|
|
|
emailAndPassword: {
|
|
// if DISABLE_LOCAL_AUTH is set to "1" or "true" then local auth is disabled
|
|
enabled: process.env.DISABLE_LOCAL_AUTH?.toLowerCase() !== 'true' && process.env.DISABLE_LOCAL_AUTH !== '1',
|
|
disableSignUp: process.env.DISABLE_SIGNUP?.toLowerCase() === 'true' || process.env.DISABLE_SIGNUP === '1',
|
|
},
|
|
});
|