fix(dev): seed the mobile OAuth client so dev sign-in works #149

Merged
ullrich merged 1 commit from seed-mobile-oauth-client into main 2026-09-12 07:33:41 +00:00
Owner

Signing in from the mobile app against a local journal fails:

{"error":"invalid_client","error_description":"Unknown client or redirect URI"}

journal.oauth_clients is empty on any fresh dev database.

Cause

seedOAuthClient("trails-cool-mobile", "trailscool://auth/callback", true) is called inside server.listen() in apps/journal/server.ts:102. But journal's scripts are:

"dev":   "react-router dev",                      // Vite — server.ts never loads
"start": "node --experimental-strip-types server.ts"

So the client is registered in production only. Mobile sign-in has never been able to work in dev without someone inserting the row by hand.

Fix

Seed it in scripts/seed.ts, which both pnpm dev:full and pnpm dev:reset run. The insert is onConflictDoNothing, so it's idempotent and leaves the production path in server.ts as the source of truth for deployed instances.

Verification

Against a local stack, with the row deleted to simulate a fresh DB:

Request Before After pnpm db:seed
/oauth/authorize?client_id=trails-cool-mobile&… 400 invalid_client 302 → /auth/login?returnTo=…
/oauth/authorize?client_id=bogus&… 400 invalid_client 400 invalid_client (still rejected)

End-to-end: sign-in from the Android emulator completes and lands on the Map tab.

pnpm typecheck 14/14, pnpm test 12/12, pnpm lint 14/14.

🤖 Generated with Claude Code

Signing in from the mobile app against a local journal fails: ```json {"error":"invalid_client","error_description":"Unknown client or redirect URI"} ``` `journal.oauth_clients` is empty on any fresh dev database. ### Cause `seedOAuthClient("trails-cool-mobile", "trailscool://auth/callback", true)` is called inside `server.listen()` in `apps/journal/server.ts:102`. But journal's scripts are: ```json "dev": "react-router dev", // Vite — server.ts never loads "start": "node --experimental-strip-types server.ts" ``` So the client is registered **in production only**. Mobile sign-in has never been able to work in dev without someone inserting the row by hand. ### Fix Seed it in `scripts/seed.ts`, which both `pnpm dev:full` and `pnpm dev:reset` run. The insert is `onConflictDoNothing`, so it's idempotent and leaves the production path in `server.ts` as the source of truth for deployed instances. ### Verification Against a local stack, with the row deleted to simulate a fresh DB: | Request | Before | After `pnpm db:seed` | |---|---|---| | `/oauth/authorize?client_id=trails-cool-mobile&…` | `400 invalid_client` | `302 → /auth/login?returnTo=…` | | `/oauth/authorize?client_id=bogus&…` | `400 invalid_client` | `400 invalid_client` (still rejected) | End-to-end: sign-in from the Android emulator completes and lands on the Map tab. `pnpm typecheck` 14/14, `pnpm test` 12/12, `pnpm lint` 14/14. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
fix(dev): seed the mobile OAuth client so dev sign-in works
All checks were successful
CI / Security Scan (pull_request) Successful in 59s
CI / Dockerfile Package Check (pull_request) Successful in 48s
CI / Checks (pull_request) Successful in 7m41s
CI / Visual Tests (pull_request) Successful in 1m57s
CI / Journal Image Smoke Test (pull_request) Successful in 7m42s
CI / E2E Tests (pull_request) Successful in 4m4s
CD Staging / Build & Push Docker Images (pull_request) Has been skipped
CD Staging / Build & Push Docker Images-1 (pull_request) Has been skipped
CD Staging / Deploy Staging (pull_request) Has been skipped
CD Staging / Deploy PR Preview (pull_request) Has been skipped
Cancel superseded CI / Cancel in-flight CI (pull_request) Successful in 18s
CD Staging / Tear Down PR Preview (pull_request) Successful in 43s
21bc174d80
Signing in from the mobile app against a local journal failed with:

    {"error":"invalid_client",
     "error_description":"Unknown client or redirect URI"}

journal.oauth_clients was empty. seedOAuthClient("trails-cool-mobile",
…) is called inside server.listen() in apps/journal/server.ts, but that
file only runs under `pnpm start`; dev uses `react-router dev`. So the
client is registered in production and never in dev, and mobile sign-in
could not work on any fresh dev database.

Seeding it in scripts/seed.ts fixes it for every dev environment, since
both `pnpm dev:full` and `pnpm dev:reset` run that script. The insert is
onConflictDoNothing, so it stays idempotent alongside the production
path, which remains the source of truth for deployed instances.

Verified against a local stack: with the row absent, /oauth/authorize
returns 400 invalid_client; after `pnpm db:seed` the same request
returns 302 to /auth/login with the correct returnTo, and an unknown
client_id is still rejected.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
trails-cool/trails!149
No description provided.