The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Revert "Share OAuth cookies across dub.co subdomains"
Rafi077976bc2629
diff --git a/apps/web/lib/auth/options.ts b/apps/web/lib/auth/options.tsindex 3180ca5e88..22f0f13b88 100644--- a/apps/web/lib/auth/options.ts+++ b/apps/web/lib/auth/options.ts@@ -38,21 +38,6 @@ import { trackDubLead } from "./track-dub-lead";const VERCEL_DEPLOYMENT = !!process.env.VERCEL_URL;-// Share auth cookies across subdomains. OAuth callbacks always land on-// NEXTAUTH_URL (app.dub.co), even when sign-in starts on partners.dub.co.-const sharedCookie = (name: string, options?: { maxAge: number }) => ({- name: `${VERCEL_DEPLOYMENT ? "__Secure-" : ""}next-auth.${name}`,- options: {- httpOnly: true,- sameSite: "lax" as const,- path: "/",- // When working on localhost, the cookie domain must be omitted entirely (https://stackoverflow.com/a/1188145)- domain: VERCEL_DEPLOYMENT ? ".dub.co" : undefined,- secure: VERCEL_DEPLOYMENT,- ...options,- },-});-const CustomPrismaAdapter = (p: PrismaClient) => {return {...PrismaAdapter(p),@@ -393,11 +378,17 @@ export const authOptions: NextAuthOptions = {adapter: CustomPrismaAdapter(prisma),session: { strategy: "jwt" },cookies: {- sessionToken: sharedCookie("session-token"),- callbackUrl: sharedCookie("callback-url"),- state: sharedCookie("state", { maxAge: 60 * 15 }),- pkceCodeVerifier: sharedCookie("pkce.code_verifier", { maxAge: 60 * 15 }),- nonce: sharedCookie("nonce"),+ sessionToken: {+ name: `${VERCEL_DEPLOYMENT ? "__Secure-" : ""}next-auth.session-token`,+ options: {+ httpOnly: true,+ sameSite: "lax",+ path: "/",+ // When working on localhost, the cookie domain must be omitted entirely (https://stackoverflow.com/a/1188145)+ domain: VERCEL_DEPLOYMENT ? ".dub.co" : undefined,+ secure: VERCEL_DEPLOYMENT,+ },+ },},pages: {signIn: "/login",