Skip to content

fix: persist mobile sessions by matching the API auth cookie prefix - #155

Open
adelrodriguez wants to merge 2 commits into
mainfrom
t3code/fix-expo-cookie-prefix
Open

fix: persist mobile sessions by matching the API auth cookie prefix#155
adelrodriguez wants to merge 2 commits into
mainfrom
t3code/fix-expo-cookie-prefix

Conversation

@adelrodriguez

Copy link
Copy Markdown
Collaborator

Stacked on #151. Flagged there by review: the generated Expo auth client has never persisted a session, against either cookie prefix. @better-auth/expo gates all cookie storage behind a startsWith(cookiePrefix) check that defaults to "better-auth", and our expoClient wrapper never passed cookiePrefix — so every init.* (and now init-api.*) cookie the API issues was silently dropped and mobile users were signed out on every app restart.

The wrapper now passes the API's cookie prefix, since the generated mobile client targets apps/api (EXPO_PUBLIC_API_URL=http://localhost:3000). Callers can still override it via the options spread when pointing at a different backend.

Along the way the init-api prefix moved from an inline template literal in apps/api into AUTH_API_COOKIE_PREFIX in packages/auth/src/constants.ts, so both sites that must agree on it — the API's auth instance and the Expo client — read one constant.

Written by Claude Fable 5 via Claude Code.

🤖 Generated with Claude Code

@pullfrog

pullfrog Bot commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

Pullfrog stalled — likely cause: quota error

The agent stopped emitting events for 120s and was killed by the activity-timeout watchdog. 88 events were processed before the failure.

Recent agent stderr
timestamp=2026-08-23T16:20:45.846Z level=ERROR run=80ef9d06 message="stream error" providerID=opencode modelID=claude-opus-5 session.id=ses_fd0936035ffeSBoDC2yZi0QsBO small=false agent=build mode=primary error.error="AI_APICallError: Subscription quota exceeded. Retry in 7hr 40min."

Pullfrog  | Rerun failed job ➔View workflow run | via Pullfrog | Using Claude Opus𝕏

@vercel

vercel Bot commented Aug 23, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
init Ready Ready Preview Aug 27, 2026 5:03am
init-docs Ready Ready Preview Aug 27, 2026 5:03am

Request Review

Base automatically changed from t3code/optimize-portless-setup to main August 27, 2026 04:43
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@adelrodriguez
adelrodriguez force-pushed the t3code/fix-expo-cookie-prefix branch from e1d22c1 to 1e3a85f Compare August 27, 2026 04:57
@vercel
vercel Bot temporarily deployed to Preview – init August 27, 2026 04:57 Inactive
@vercel
vercel Bot temporarily deployed to Preview – init-docs August 27, 2026 04:57 Inactive

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

The new shared default breaks session persistence for the generated Convex mobile client and must be corrected before merge.

Reviewed changes

Reviewed the complete rebased authentication change because no earlier Pullfrog review exists.

  • Centralized the API prefix: Added AUTH_API_COOKIE_PREFIX and used it in the Hono API auth configuration.
  • Changed Expo cookie filtering: Made the shared Expo client default to the Hono API's init-api cookie prefix while retaining caller overrides.

Pullfrog  | Fix all ➔Fix 👍s ➔View workflow run | Using GPT Sol𝕏

Comment thread packages/auth/src/expo/client.ts Outdated
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@adelrodriguez

Copy link
Copy Markdown
Collaborator Author

claude-fable-5 (on behalf of Adel):

Good catch — confirmed against packages/backend/src/functions/shared/auth.ts (Convex uses the un-namespaced AUTH_ADVANCED_OPTIONS, so it issues init.*) and the Convex mobile template, which relies on the wrapper default. Fixed in 8e712d4 with your suggested shape: the shared wrapper defaults to the backend-neutral AUTH_COOKIE_PREFIX, and the Hono mobile template passes cookiePrefix: AUTH_API_COOKIE_PREFIX explicitly. Both generated clients now match their backend's cookie names.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

Reviewed the backend-neutral cookie-prefix correction added since the prior Pullfrog review.

  • Restored the shared prefix: Changed the Expo wrapper default to AUTH_COOKIE_PREFIX, which preserves Convex mobile sessions.
  • Scoped the Hono override: Passed AUTH_API_COOKIE_PREFIX from the Hono mobile auth template, so generated API clients persist init-api.* cookies.

Pullfrog  | View workflow run | Using GPT Sol𝕏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant