Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

use waitUntil

Steven Tey299244aecb43
diff --git a/apps/web/lib/auth/options.ts b/apps/web/lib/auth/options.ts
index 8ec406ae39..7da63df9c1 100644
--- a/apps/web/lib/auth/options.ts
+++ b/apps/web/lib/auth/options.ts
@@ -2,6 +2,7 @@ import { isBlacklistedEmail } from "@/lib/edge-config";
import jackson from "@/lib/jackson";
import { prisma } from "@/lib/prisma";
import { PrismaAdapter } from "@next-auth/prisma-adapter";
+import { waitUntil } from "@vercel/functions";
import { sendEmail } from "emails";
import LoginLink from "emails/login-link";
import WelcomeEmail from "emails/welcome-email";
@@ -24,29 +25,32 @@ export const authOptions: NextAuthOptions = {
providers: [
EmailProvider({
async sendVerificationRequest({ identifier, url }) {
- let link = url;
- try {
- const { shortLink } = await dub.links.create({
- domain: "d.to",
- url,
- archived: true,
- tagIds: ["clz20tm1f0003onht3q6f11me"],
- });
- link = shortLink;
- } catch (error) {
- console.error(error);
- }
-
- if (process.env.NODE_ENV === "development") {
- console.log(`Login link: ${link}`);
- return;
- } else {
- await sendEmail({
- email: identifier,
- subject: `Your ${process.env.NEXT_PUBLIC_APP_NAME} Login Link`,
- react: LoginLink({ url, email: identifier }),
- });
- }
+ waitUntil(
+ (async () => {
+ let link = url;
+ try {
+ const { shortLink } = await dub.links.create({
+ domain: "d.to",
+ url,
+ archived: true,
+ tagIds: ["clz20tm1f0003onht3q6f11me"],
+ });
+ link = shortLink;
+ } catch (error) {
+ console.error(error);
+ }
+ if (process.env.NODE_ENV === "development") {
+ console.log(`Login link: ${link}`);
+ return;
+ } else {
+ await sendEmail({
+ email: identifier,
+ subject: `Your ${process.env.NEXT_PUBLIC_APP_NAME} Login Link`,
+ react: LoginLink({ url: link, email: identifier }),
+ });
+ }
+ })(),
+ );
},
}),
GoogleProvider({