wu981526092 commited on
Commit
a093720
·
1 Parent(s): e3fcbe2

Fix: Correct OAuth callback URL path mismatch

Browse files

🐛 Problem:
- Frontend uses /oauth-callback but backend expects /auth/oauth-callback
- HF OAuth redirects to /oauth-callback which returns 404
- Path inconsistency between frontend and backend routes

✅ Solution:
- Updated frontend redirectUri to use /auth/oauth-callback
- Updated backend redirect_uri construction to match
- Now both frontend and backend use consistent /auth/oauth-callback path

🔧 Technical Changes:
Frontend:
- AuthContext: redirectUri = /auth/oauth-callback

Backend:
- auth.py: redirect_uri = /auth/oauth-callback (all instances)
- Maintains router prefix consistency: /auth + /oauth-callback

🎯 Expected Result:
- OAuth callback should now route correctly to backend handler
- No more 404 errors after HF authorization
- Complete OAuth flow from authorization to app login

backend/routers/auth.py CHANGED
@@ -114,7 +114,7 @@ async def login(request: Request):
114
  else:
115
  base_url = str(request.base_url).rstrip('/')
116
 
117
- redirect_uri = f"{base_url}/oauth-callback"
118
 
119
  # Build authorization URL
120
  auth_url = (
@@ -189,7 +189,7 @@ async def handle_oauth_callback(request: Request, code: str, state: str):
189
  else:
190
  base_url = str(request.base_url).rstrip('/')
191
 
192
- redirect_uri = f"{base_url}/oauth-callback"
193
 
194
  try:
195
  token_response = requests.post(
 
114
  else:
115
  base_url = str(request.base_url).rstrip('/')
116
 
117
+ redirect_uri = f"{base_url}/auth/oauth-callback"
118
 
119
  # Build authorization URL
120
  auth_url = (
 
189
  else:
190
  base_url = str(request.base_url).rstrip('/')
191
 
192
+ redirect_uri = f"{base_url}/auth/oauth-callback"
193
 
194
  try:
195
  token_response = requests.post(
frontend/src/context/AuthContext.tsx CHANGED
@@ -236,7 +236,7 @@ export function AuthProvider({ children }: { children: ReactNode }) {
236
 
237
  // Direct OAuth URL construction with backend-provided client_id
238
  const baseUrl = window.location.origin;
239
- const redirectUri = `${baseUrl}/oauth-callback`;
240
 
241
  // Create state for CSRF protection
242
  const state = Math.random().toString(36).substring(2, 15);
 
236
 
237
  // Direct OAuth URL construction with backend-provided client_id
238
  const baseUrl = window.location.origin;
239
+ const redirectUri = `${baseUrl}/auth/oauth-callback`;
240
 
241
  // Create state for CSRF protection
242
  const state = Math.random().toString(36).substring(2, 15);