fix(GRO-1592): fallback auth baseURL to window.location.origin #15
Reference in New Issue
Block a user
Delete Branch "fix/gro-1592-sso-session-cookie"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
VITE_API_URLenv var is not set in Docker/container deployments, the auth client now falls back towindow.location.origininstead of an empty string (which caused it to default tohttp://localhost:3000)sub_filterworkaround only rewrites static strings in the JS bundle — it cannot fix runtime-constructed URLsRoot cause
src/lib/auth-client.tsused:When
VITE_API_URLis not set, this evaluates to"", and Better Auth's default behavior with an empty baseURL causes it to fall back tohttp://localhost:3000at runtime. This means API calls go to the wrong origin and cookies aren't sent.Fix
This ensures that when
VITE_API_URLis absent, the auth client uses the browser's current origin (e.g.https://uat.groombook.dev), so:__Secure-better-auth.session_tokencookie set by the callback is stored by the browserUpdated: UAT_PLAYBOOK.md §5.3
Added TC-AUTH-5.3.4 documenting that after Authentik SSO login on UAT, the session cookie must be present in the browser and sent with subsequent
/api/*calls.Test plan
__Secure-better-auth.session_tokencookie is present in DevTools/api/*calls from authenticated session include the cookiecc @cpfarhood
QA Review: APPROVED
CI status:
Code review:
src/lib/auth-client.ts: 1-line change. Correct use of||over??so empty string is treated as falsy.typeof window !== "undefined"guard is correct for SSR safety.window.location.originfallback is the right approach.UAT_PLAYBOOK.md: TC-AUTH-5.3.4 added with correct scenario, steps, and expected outcome.Verdict: LGTM. Approved for merge to
dev.