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:
parent
a83940ddfc
commit
a85f67c298
@ -1,4 +1,4 @@
|
|||||||
import { env, waitUntil } from "cloudflare:workers";
|
import { env } from "cloudflare:workers";
|
||||||
import { betterAuth } from "better-auth";
|
import { betterAuth } from "better-auth";
|
||||||
import { drizzleAdapter } from "better-auth/adapters/drizzle";
|
import { drizzleAdapter } from "better-auth/adapters/drizzle";
|
||||||
import { tanstackStartCookies } from "better-auth/tanstack-start";
|
import { tanstackStartCookies } from "better-auth/tanstack-start";
|
||||||
@ -29,13 +29,6 @@ function createAuth() {
|
|||||||
baseURL: baseUrl,
|
baseURL: baseUrl,
|
||||||
secret: getHostedSecret(),
|
secret: getHostedSecret(),
|
||||||
...baseAuthConfig,
|
...baseAuthConfig,
|
||||||
advanced: {
|
|
||||||
backgroundTasks: {
|
|
||||||
handler: (promise) => {
|
|
||||||
waitUntil(promise);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
emailAndPassword: {
|
emailAndPassword: {
|
||||||
...baseAuthConfig.emailAndPassword,
|
...baseAuthConfig.emailAndPassword,
|
||||||
requireEmailVerification: true,
|
requireEmailVerification: true,
|
||||||
|
|||||||
@ -67,8 +67,8 @@ function getVerifyEmailPageCopy({
|
|||||||
|
|
||||||
if (isWaiting && email) {
|
if (isWaiting && email) {
|
||||||
return {
|
return {
|
||||||
title: "Check your email",
|
title: "Verify your email",
|
||||||
helperText: `We sent a confirmation link to ${email}. Open it to confirm your email.`,
|
helperText: `Click the link we sent to ${email} to verify your email.`,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,7 +161,7 @@ function VerifyEmailPage() {
|
|||||||
search={getSignInSearch(redirectTo)}
|
search={getSignInSearch(redirectTo)}
|
||||||
className="text-base-content/50 hover:text-base-content transition-colors"
|
className="text-base-content/50 hover:text-base-content transition-colors"
|
||||||
>
|
>
|
||||||
Sign in
|
Back to sign in
|
||||||
</Link>
|
</Link>
|
||||||
</p>
|
</p>
|
||||||
}
|
}
|
||||||
@ -181,19 +181,13 @@ function VerifyEmailPage() {
|
|||||||
</div>
|
</div>
|
||||||
) : isWaiting ? (
|
) : isWaiting ? (
|
||||||
<div className="space-y-4">
|
<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
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className="btn btn-soft w-full"
|
className="btn btn-soft w-full"
|
||||||
onClick={() => void handleResend()}
|
onClick={() => void handleResend()}
|
||||||
disabled={isResending}
|
disabled={isResending}
|
||||||
>
|
>
|
||||||
{isResending ? "Sending email..." : "Send another email"}
|
{isResending ? "Sending email..." : "Resend email"}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
) : isPending ? (
|
) : isPending ? (
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user