1. Brevo email integration (API key, sender settings)

2. URL configuration fix (BASE_URL, FRONTEND_URL)
  3. Password reset URL pointing to frontend instead of API
This commit is contained in:
Wuesteon 2025-12-16 21:12:25 +01:00
parent 3e3e9f33aa
commit 8c973e4354
7 changed files with 42 additions and 4 deletions

View file

@ -40,5 +40,11 @@ RATE_LIMIT_MAX=100
# Get your API key from: https://app.brevo.com/settings/keys/api
# Without this key, emails are logged to console only (dev mode)
BREVO_API_KEY=
EMAIL_SENDER_ADDRESS=noreply@manacore.app
EMAIL_SENDER_ADDRESS=noreply@manacore.ai
EMAIL_SENDER_NAME=ManaCore
# URLs
# BASE_URL: Used by Better Auth for internal callbacks
# FRONTEND_URL: Used for password reset and email verification links
BASE_URL=http://localhost:3001
FRONTEND_URL=http://localhost:5173

View file

@ -126,13 +126,20 @@ export function createBetterAuth(databaseUrl: string) {
* Set BREVO_API_KEY environment variable to enable email sending.
* Without the API key, emails are logged to console (dev mode).
*
* The reset URL points to the frontend's reset-password page, not the API.
* Set FRONTEND_URL environment variable for production.
*
* @see https://www.better-auth.com/docs/authentication/email-password#password-reset
*/
sendResetPassword: async ({ user, url }) => {
sendResetPassword: async ({ user, token }) => {
// Construct URL pointing to frontend's reset-password page
const frontendUrl = process.env.FRONTEND_URL || 'http://localhost:5173';
const resetUrl = `${frontendUrl}/reset-password?token=${token}`;
await sendPasswordResetEmail({
email: user.email,
name: user.name || undefined,
resetUrl: url,
resetUrl,
});
},
},

View file

@ -52,7 +52,12 @@ export default () => ({
email: {
brevoApiKey: process.env.BREVO_API_KEY || '',
senderAddress: process.env.EMAIL_SENDER_ADDRESS || 'noreply@manacore.app',
senderAddress: process.env.EMAIL_SENDER_ADDRESS || 'noreply@manacore.ai',
senderName: process.env.EMAIL_SENDER_NAME || 'ManaCore',
},
urls: {
baseUrl: process.env.BASE_URL || 'http://localhost:3001',
frontendUrl: process.env.FRONTEND_URL || 'http://localhost:5173',
},
});