Skip to content

Commit 7db3a00

Browse files
committed
Fix OAuth redirect to use correct port (8080) for localhost
1 parent 767fe49 commit 7db3a00

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

AUTH_SETUP.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,21 @@
3737

3838
1. Go to: https://console.cloud.google.com/apis/credentials
3939
2. Click on your **OAuth 2.0 Client ID**
40-
3. Under **Authorized redirect URIs**, add:
40+
3. Under **Authorized redirect URIs**, add **ALL of these**:
4141
```
4242
https://banyhroaktppyqtspznt.supabase.co/auth/v1/callback
43+
http://localhost:8080
44+
http://localhost:3000
4345
```
44-
4. Click **Save**
46+
4. Under **Authorized JavaScript origins**, add:
47+
```
48+
http://localhost:8080
49+
https://bb84-simulation.vercel.app
50+
```
51+
5. Click **Save**
52+
6. **Wait 5-10 minutes** for Google to propagate the changes
4553

46-
✅ This allows Google OAuth to redirect back to your app.
54+
✅ This allows Google OAuth to redirect back to your app on the correct port.
4755

4856
---
4957

src/lib/supabase.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,16 @@ export interface LeaderboardEntry {
2828

2929
// Auth helper functions
3030
export const signInWithGoogle = async () => {
31+
// Determine the correct redirect URL based on environment
32+
const isDev = window.location.hostname === 'localhost';
33+
const redirectTo = isDev
34+
? 'http://localhost:8080/#/quiz'
35+
: 'https://bb84-simulation.vercel.app/#/quiz';
36+
3137
const { data, error } = await supabase.auth.signInWithOAuth({
3238
provider: 'google',
3339
options: {
34-
redirectTo: `${window.location.origin}/#/quiz`,
40+
redirectTo,
3541
},
3642
});
3743
return { data, error };

0 commit comments

Comments
 (0)