export const auth = betterAuth({
appName: APP_NAME,
secret: envVariables.BETTER_AUTH_SECRET,
baseURL: import.meta.env.VITE_BASE_URL || "http://localhost:3000",
database: instantDBAdapter({
db: instantServerDB,
usePlural: true, // Our schema uses plural form
debugLogs: true, // Enable debug logs to trace issues
}),
trustedOrigins: [
"http://localhost:3000",
"http://localhost:3001",
"https://moneymouth.ai",
...(import.meta.env.VITE_BASE_URL ? [import.meta.env.VITE_BASE_URL] : []),
],
plugins: [
magicLink({
// Auto-create users when they use magic links
disableSignUp: false,
expiresIn: 60 * 60 * 24 * 365 * 100, // 100 years in seconds
sendMagicLink: async ({ email, token, url }, request) => {
console.log("🔗 Magic link handler started");
console.log("🔗 Email:", email);
console.log("🔗 Token:", token);
console.log("🔗 URL:", url);
// Send the ebook email with magic link
await sendEbookEmail({ email, token, url });
console.log("📧 Magic link email sent successfully to:", email);
},
}),
],
user: {
changeEmail: {
enabled: true,
},
deleteUser: {
enabled: true,
},
},
});
export const auth = betterAuth({
appName: APP_NAME,
secret: envVariables.BETTER_AUTH_SECRET,
baseURL: import.meta.env.VITE_BASE_URL || "http://localhost:3000",
database: instantDBAdapter({
db: instantServerDB,
usePlural: true, // Our schema uses plural form
debugLogs: true, // Enable debug logs to trace issues
}),
trustedOrigins: [
"http://localhost:3000",
"http://localhost:3001",
"https://moneymouth.ai",
...(import.meta.env.VITE_BASE_URL ? [import.meta.env.VITE_BASE_URL] : []),
],
plugins: [
magicLink({
// Auto-create users when they use magic links
disableSignUp: false,
expiresIn: 60 * 60 * 24 * 365 * 100, // 100 years in seconds
sendMagicLink: async ({ email, token, url }, request) => {
console.log("🔗 Magic link handler started");
console.log("🔗 Email:", email);
console.log("🔗 Token:", token);
console.log("🔗 URL:", url);
// Send the ebook email with magic link
await sendEbookEmail({ email, token, url });
console.log("📧 Magic link email sent successfully to:", email);
},
}),
],
user: {
changeEmail: {
enabled: true,
},
deleteUser: {
enabled: true,
},
},
});