Skip to content

fix(github-app): reconnect uses POST /api/auth/login, not bare URL#46

Open
ABB65 wants to merge 1 commit into
mainfrom
fix/github-reconnect-oauth-redirect
Open

fix(github-app): reconnect uses POST /api/auth/login, not bare URL#46
ABB65 wants to merge 1 commit into
mainfrom
fix/github-reconnect-oauth-redirect

Conversation

@ABB65
Copy link
Copy Markdown
Member

@ABB65 ABB65 commented May 13, 2026

Summary

Follow-up to PR #45 — observed on staging immediately after merge.

The new "Reconnect GitHub" button in `ConnectRepoDialog` was building a GET URL to `/api/auth/login`:

```ts
window.location.href = `/api/auth/login?provider=github&redirect_to=${...}`
```

But `/api/auth/login` only exposes a POST handler (`server/api/auth/login.post.ts` — body shape `{provider, redirectTo}`, CSRF-state cookie). Browser GET hits 404.

Observed:
```
https://studio-staging-5610.up.railway.app/api/auth/login?provider=github&redirect_to=/w/---65-b9b4db78
→ 404 Page Not Found
```

Fix

Switch to `useAuth().signInWithOAuth('github')` — the same path the regular sign-in screen uses. Bonus: `useWorkspaces().saveLastPath(...)` is called before the redirect so the user lands back on the project they came from once OAuth completes (the workspace bootstrap restores from `cr-last-path` localStorage key).

Test plan

  • `pnpm typecheck` — clean
  • `pnpm lint` — 0 errors
  • Staging: ConnectRepoDialog → connect-existing → if user has no provider_token → "Reconnect GitHub" button → opens GitHub OAuth (not 404)
  • Staging: OAuth complete → user back on `/w/.../projects/...` (not `/`)

The previous reconnect flow built a GET URL to /api/auth/login —
which only exposes a POST handler (with CSRF-state cookie + body
shape). Browser hits to that path 404 the user out instead of
starting OAuth.

Switch to `useAuth().signInWithOAuth('github')` so the reconnect
path uses the exact same endpoint (and state-cookie protocol) as
the regular sign-in screen. Save the current path via
`useWorkspaces().saveLastPath` so the user lands back on the
project they came from once OAuth completes.

Observed on staging: clicking "Reconnect GitHub" on the
ConnectRepoDialog's connect-existing empty state landed on:
  /api/auth/login?provider=github&redirect_to=/w/...   → 404
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