From 2cc2834e0fc3396b03ee5d9fdbb6bb6baefcfe6b Mon Sep 17 00:00:00 2001 From: Adrian Bonpin Date: Sun, 26 Apr 2026 19:35:45 +0800 Subject: [PATCH] fix: align auth env var naming with NEXT_PUBLIC_SITE_URL --- .env.example | 3 +++ lib/auth-client.ts | 2 +- lib/auth.ts | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.env.example b/.env.example index ad89e37..322806c 100644 --- a/.env.example +++ b/.env.example @@ -25,6 +25,9 @@ NEXT_PUBLIC_SITE_URL="https://localhost:3000" # Auth callback URL NEXT_PUBLIC_APP_URL="https://localhost:3000" +# Used by Better Auth trusted origins and auth client baseURL (same as NEXT_PUBLIC_SITE_URL) +NEXT_PUBLIC_BASE_URL="https://localhost:3000" + # ----------------------------------------------------------------------------- # BETTER AUTH # ----------------------------------------------------------------------------- diff --git a/lib/auth-client.ts b/lib/auth-client.ts index ee78e6d..0055432 100644 --- a/lib/auth-client.ts +++ b/lib/auth-client.ts @@ -3,7 +3,7 @@ import { adminClient, emailOTPClient, lastLoginMethodClient } from 'better-auth/ import { passkeyClient } from '@better-auth/passkey/client' export const authClient = createAuthClient({ - baseURL: process.env.NEXT_PUBLIC_BASE_URL || "https://localhost:3000", + baseURL: process.env.NEXT_PUBLIC_SITE_URL || "https://localhost:3000", plugins: [ emailOTPClient(), passkeyClient(), diff --git a/lib/auth.ts b/lib/auth.ts index 1e93bdb..3bf8fde 100644 --- a/lib/auth.ts +++ b/lib/auth.ts @@ -49,7 +49,7 @@ export const auth = betterAuth({ clientSecret: process.env.DISCORD_CLIENT_SECRET || "", }, }, - trustedOrigins: [process.env.NEXT_PUBLIC_BASE_URL || "https://localhost:3000"], + trustedOrigins: [process.env.NEXT_PUBLIC_SITE_URL || "https://localhost:3000"], rateLimit: { enabled: true, window: 60,