Commit f08c50f
fix(auth): clear stale session before login/signup to stop refresh token loop
When users land on /login or /sign-up with expired auth cookies, the
Supabase client singleton starts an auto-refresh loop with the stale
token (400 → 429 endlessly). The middleware fix clears cookies for the
next page load, but can't stop a JS loop already running in the browser.
Fix: call signOut({ scope: 'local' }) before signInWithPassword,
signUp, and signInWithOAuth to clear cached stale tokens from the
Supabase client's memory and cookies before attempting authentication.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 05d50ec commit f08c50f
2 files changed
Lines changed: 9 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
48 | 54 | | |
49 | 55 | | |
50 | 56 | | |
| |||
87 | 93 | | |
88 | 94 | | |
89 | 95 | | |
| 96 | + | |
90 | 97 | | |
91 | 98 | | |
92 | 99 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| 56 | + | |
56 | 57 | | |
57 | 58 | | |
58 | 59 | | |
| |||
78 | 79 | | |
79 | 80 | | |
80 | 81 | | |
| 82 | + | |
81 | 83 | | |
82 | 84 | | |
83 | 85 | | |
| |||
0 commit comments