import { betterAuth } from "better-auth"; import { prismaAdapter } from "better-auth/adapters/prisma"; import type { PrismaClient } from "@prisma/client"; export function createAuth(prisma: PrismaClient) { return betterAuth({ database: prismaAdapter(prisma, { provider: "postgresql", }), emailAndPassword: { enabled: true, // Enable for now, can be disabled later }, session: { expiresIn: 60 * 60 * 24, // 24 hours updateAge: 60 * 60 * 24, // 24 hours }, trustedOrigins: [ process.env.NEXT_PUBLIC_APP_URL ?? "http://localhost:3000", "http://localhost:3001", // API origin ], }); } export type Auth = ReturnType;