Prefer Supabase SMTP for verification emails; fallback to server endpoint

cgen-6dc427ca42924f7982520fb28ca57b69
This commit is contained in:
Builder.io 2025-10-17 23:46:11 +00:00
parent b24add0a88
commit 3aa41f8784

View file

@ -83,6 +83,21 @@ export default function Welcome({
setFallbackVerificationLink(null);
try {
// First try Supabase to send via your configured SMTP
const { error: resendError } = await supabase.auth.resend({
type: "signup",
email: emailAddress,
} as any);
if (!resendError) {
toastSuccess({
title: "Verification email sent",
description: `We sent a confirmation message to ${emailAddress}.`,
});
return;
}
// Fallback to server-generated link (and optional Resend delivery)
const redirectTo =
typeof window !== "undefined"
? `${window.location.origin}/login?verified=1`
@ -103,7 +118,6 @@ export default function Welcome({
.catch(() => ({}) as Record<string, any>);
if (!response.ok) {
// If server returned a manual verification link despite the error, surface it to the user.
const manualLink =
typeof payload?.verificationUrl === "string"
? payload.verificationUrl
@ -126,8 +140,6 @@ export default function Welcome({
"Failed to send verification email",
});
}
setIsSendingVerification(false);
return;
}