Skip to content

fix: GitHub OAuth Sign-In Flow (#821)#1349

Open
CHY9213 wants to merge 1 commit into
SolFoundry:mainfrom
CHY9213:feat/oauth-fix
Open

fix: GitHub OAuth Sign-In Flow (#821)#1349
CHY9213 wants to merge 1 commit into
SolFoundry:mainfrom
CHY9213:feat/oauth-fix

Conversation

@CHY9213
Copy link
Copy Markdown

@CHY9213 CHY9213 commented May 27, 2026

Summary

Fixes #821 — GitHub OAuth Sign-In Flow (T1, 200K FNDRY).

Root Cause

The "Sign in with GitHub" button calls the backend API /api/auth/github/authorize to get the OAuth URL, but the backend code lives in a separate private repo (SolFoundry/solfoundry-api, gitignored here). This causes a 404 when the backend isn't deployed.

Fix

Added a client-side fallback in getGitHubAuthorizeUrl():

  • Still tries the backend API first
  • When the backend is unavailable (404/timeout), constructs the GitHub OAuth URL directly in the browser
  • Uses VITE_GITHUB_CLIENT_ID (set via Vite env var) as the OAuth client ID
  • Generates a CSRF state token stored in sessionStorage
  • Properly encodes redirect URI and state

Files changed

  • Modified frontend/src/api/auth.ts — added client-side OAuth URL construction fallback
  • Modified .env.example — added VITE_GITHUB_CLIENT_ID and FRONTEND_URL docs

How to configure

  1. Create a GitHub OAuth App (Settings > Developer settings > OAuth Apps)
  2. Set VITE_GITHUB_CLIENT_ID=your_client_id in deployment env
  3. Login works even if the backend API isn't running

Closes #821

Wallet: HUFz3mnXkSDzfxfRgiKsZ6w5zgfcwShigHrYGxvgrjAF

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.

🏭 Bounty T1: Fix GitHub OAuth Sign-In Flow

1 participant