fix(github-app): reconnect uses POST /api/auth/login, not bare URL#46
Open
ABB65 wants to merge 1 commit into
Open
fix(github-app): reconnect uses POST /api/auth/login, not bare URL#46ABB65 wants to merge 1 commit into
ABB65 wants to merge 1 commit into
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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