35d31a984d
When VITE_API_URL is not set (e.g. in Docker/container deployments where the env var was never injected), fallback to window.location.origin so the auth client uses relative URLs and cookies are sent to the correct origin. Previously the fallback was empty string "", which caused the auth client to default to http://localhost:3000 — the nginx sub_filter workaround only handles strings baked into the JS bundle at build time, not runtime-constructed URLs. Fixes: SSO session cookie not set in browser after Authentik callback Co-Authored-By: Paperclip <noreply@paperclip.ing>
7 lines
285 B
TypeScript
7 lines
285 B
TypeScript
import { createAuthClient } from "better-auth/react";
|
|
|
|
export const authClient = createAuthClient({
|
|
baseURL: import.meta.env.VITE_API_URL || (typeof window !== "undefined" ? window.location.origin : ""),
|
|
});
|
|
|
|
export const { signIn, signOut, useSession, changePassword } = authClient; |