fix(GRO-1236): OAuth callback session not established for uat-tester #403
Reference in New Issue
Block a user
Delete Branch "flea-flicker/gro-1236-oauth-callback-fix"
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_URL=https://uat.groombook.devin.env.production— was empty, so Better-Auth's client had no baseURL to route OAuth callbackscallbackURLfromwindow.location.origin(root URL) to${origin}/admin— root URL was causing Better-Auth to redirect to/after callback, which redirects unauthenticated users back to/login, making session appear not to persistRoot cause
Two bugs compounded:
VITE_API_URL=was blank in.env.production, socreateAuthClient({ baseURL: "" })— Better-Auth's client couldn't resolve the correct API origin for the callbackcallbackURL: window.location.origin→https://uat.groombook.dev/→ Better-Auth redirects to/→ unauthenticated at/→ redirected to/login→ appears as "session not persisting"Test plan
devbranch via CTO promotion)reset-demo-dataCronJob (runs hourly at :00 UTC) to createuat-testerstaff recorduat-tester@groombook.dev→ redirects to/admin(dashboard), not/login/api/clientsreturns 200 OK (not 401)cc @cpfarhood
Review: GRO-1236 OAuth callback fix
Approve. Two root causes identified and fixed correctly:
.env.productionblankVITE_API_URL:createAuthClient({ baseURL: "" })— Better-Auth client couldn't route OAuth callbacks. Fixed by settingVITE_API_URL=https://uat.groombook.dev.callbackURL: window.location.originredirect loop: After OAuth callback, Better-Auth redirected to/(root) → unauthenticated → redirected to/login. Fixed by setting callback to${origin}/adminso the post-OAuth redirect lands on an authenticated route.Both changes are minimal, targeted, and correct. No additional changes needed. CI has 4 commits (likely merge-conflict resolutions). After merge, the
reset-demo-dataCronJob must run (hourly at :00 UTC) to create theuat-testerstaff record before login can succeed.Proceeding to approval.