fix: remove better auth background tasks (#67)

* Improve verify email page copy and design

Remove redundant green success alert, update title to "Verify your email",
rename button to "Resend email", and change footer link to "Back to sign in".

* Fix verification emails not sending in production

Remove the backgroundTasks/waitUntil handler so better-auth awaits
email sending inline. Previously, errors thrown inside waitUntil
promises were silently dropped by Cloudflare Workers, preventing
emails from sending with no visible error logs.
This commit is contained in:
Ben Senescu 2026-04-03 19:00:05 -04:00 committed by Ben Senescu
parent a83940ddfc
commit a85f67c298
2 changed files with 5 additions and 18 deletions

View File

@ -1,4 +1,4 @@
import { env, waitUntil } from "cloudflare:workers";
import { env } from "cloudflare:workers";
import { betterAuth } from "better-auth";
import { drizzleAdapter } from "better-auth/adapters/drizzle";
import { tanstackStartCookies } from "better-auth/tanstack-start";
@ -29,13 +29,6 @@ function createAuth() {
baseURL: baseUrl,
secret: getHostedSecret(),
...baseAuthConfig,
advanced: {
backgroundTasks: {
handler: (promise) => {
waitUntil(promise);
},
},
},
emailAndPassword: {
...baseAuthConfig.emailAndPassword,
requireEmailVerification: true,

View File

@ -67,8 +67,8 @@ function getVerifyEmailPageCopy({
if (isWaiting && email) {
return {
title: "Check your email",
helperText: `We sent a confirmation link to ${email}. Open it to confirm your email.`,
title: "Verify your email",
helperText: `Click the link we sent to ${email} to verify your email.`,
};
}
@ -161,7 +161,7 @@ function VerifyEmailPage() {
search={getSignInSearch(redirectTo)}
className="text-base-content/50 hover:text-base-content transition-colors"
>
Sign in
Back to sign in
</Link>
</p>
}
@ -181,19 +181,13 @@ function VerifyEmailPage() {
</div>
) : isWaiting ? (
<div className="space-y-4">
<div className="alert alert-success">
<span>
After you click the link in your email, this page will finish up
automatically.
</span>
</div>
<button
type="button"
className="btn btn-soft w-full"
onClick={() => void handleResend()}
disabled={isResending}
>
{isResending ? "Sending email..." : "Send another email"}
{isResending ? "Sending email..." : "Resend email"}
</button>
</div>
) : isPending ? (