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.

Update check-account-exists.ts

Kiran K4155d9b504a6
diff --git a/apps/web/lib/actions/check-account-exists.ts b/apps/web/lib/actions/check-account-exists.ts
index 16bb81931f..523318a2d6 100644
--- a/apps/web/lib/actions/check-account-exists.ts
+++ b/apps/web/lib/actions/check-account-exists.ts
@@ -3,6 +3,7 @@
import { ratelimit } from "@/lib/upstash";
import { prisma } from "@dub/prisma";
import { APP_HOSTNAMES } from "@dub/utils";
+import { headers } from "next/headers";
import { getIP } from "../api/utils";
import { isGenericEmail } from "../emails";
import z from "../zod";
@@ -30,10 +31,11 @@ export const checkAccountExistsAction = actionClient
}
// Check SAML enforcement
+ const headersList = headers();
const emailDomain = email.split("@")[1];
- const hostname = new URL(process.env.NEXTAUTH_URL as string).hostname;
+ const hostname = headersList.get("host");
const shouldCheckSAML =
- APP_HOSTNAMES.has(hostname) && !isGenericEmail(emailDomain);
+ hostname && APP_HOSTNAMES.has(hostname) && !isGenericEmail(emailDomain);
const [user, workspace] = await Promise.all([
prisma.user.findUnique({