fix: Resend rejects noreply@localhost as from address
When NEXTAUTH_URL=http://localhost:3000, the hostname resolves to 'localhost' which Resend rejects. Fall back to onboarding@resend.dev when hostname is localhost. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -61,8 +61,9 @@ async function sendViaResend(apiKey: string, { to, subject, html, attachments }:
|
||||
const { Resend } = await import('resend');
|
||||
const resend = new Resend(apiKey);
|
||||
|
||||
const from = process.env.NEXTAUTH_URL
|
||||
? `Memento <noreply@${new URL(process.env.NEXTAUTH_URL).hostname}>`
|
||||
const hostname = process.env.NEXTAUTH_URL ? new URL(process.env.NEXTAUTH_URL).hostname : '';
|
||||
const from = hostname && hostname !== 'localhost'
|
||||
? `Memento <noreply@${hostname}>`
|
||||
: 'Memento <onboarding@resend.dev>';
|
||||
|
||||
// Resend supports attachments with inline content
|
||||
|
||||
Reference in New Issue
Block a user