diff --git a/apps/web/next-env.d.ts b/apps/web/next-env.d.ts index 9edff1c..c4b7818 100644 --- a/apps/web/next-env.d.ts +++ b/apps/web/next-env.d.ts @@ -1,6 +1,6 @@ /// /// -import "./.next/types/routes.d.ts"; +import "./.next/dev/types/routes.d.ts"; // NOTE: This file should not be edited // see https://nextjs.org/docs/app/api-reference/config/typescript for more information. diff --git a/apps/web/src/lib/auth.ts b/apps/web/src/lib/auth.ts index 553af54..5917597 100644 --- a/apps/web/src/lib/auth.ts +++ b/apps/web/src/lib/auth.ts @@ -3,9 +3,14 @@ import { betterAuth } from 'better-auth'; import { prismaAdapter } from 'better-auth/adapters/prisma'; import { sendVerificationEmail } from './email'; -// Determine base URL: use env var, or Vercel URL, or default to production +// Determine base URL for auth - MUST match the domain users are browsing on +// VERCEL_URL is the deployment URL (e.g., tpmjs-xxx.vercel.app), not the custom domain +// So we prioritize BETTER_AUTH_URL or fall back to the production domain const getBaseURL = () => { if (process.env.BETTER_AUTH_URL) return process.env.BETTER_AUTH_URL; + // In production, always use the custom domain, not VERCEL_URL + if (process.env.VERCEL_ENV === 'production') return 'https://tpmjs.com'; + // For preview deployments, use the Vercel URL if (process.env.VERCEL_URL) return `https://${process.env.VERCEL_URL}`; return 'https://tpmjs.com'; };