fix: infinite redirect loop between web and dashboard apps - #28
Merged
Conversation
Three interacting failures causing an infinite redirect loop with
exponentially nested redirectTo parameters:
1. Navbar Dashboard button linked to APP_URL (port 5173) instead of
DASHBOARD_URL (port 5174) — fixed to use DASHBOARD_URL from config
2. All redirect validation functions (getSafeRedirect/getRedirectTo/
isSafeRedirectPath) only checked startsWith('/') and !startsWith('//')
but accepted auth pages like /login, /signup, /forgot-password,
/reset-password, /auth/callback — added an AUTH_PATHS blocklist that
rejects these as redirect targets
3. Nesting of redirectTo query params caused encoding amplification on
each hop — added query string stripping when a redirect target
contains its own ?redirectTo= param
Additionally, added a WEB_LOGIN_URL guard in the dashboard that detects
when VITE_APP_URL resolves to the dashboard's own origin (port 5174)
instead of the web app (port 5173), preventing self-referencing
navigation that causes an infinite page reload.
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
📝 WalkthroughWalkthroughAuthentication redirects now validate ChangesAuthentication redirect flow
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant User
participant AuthRouteGuard
participant Supabase
participant DashboardAuthCallback
AuthRouteGuard->>Supabase: Fetch current session
Supabase-->>AuthRouteGuard: Return access and refresh tokens
AuthRouteGuard->>DashboardAuthCallback: Redirect with tokens and sanitized redirectTo
DashboardAuthCallback->>Supabase: Set session
DashboardAuthCallback->>User: Navigate to sanitized redirect path
Possibly related PRs
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Three interacting failures causing an infinite redirect loop with exponentially nested redirectTo parameters:
Navbar Dashboard button linked to APP_URL (port 5173) instead of DASHBOARD_URL (port 5174) — fixed to use DASHBOARD_URL from config
All redirect validation functions (getSafeRedirect/getRedirectTo/ isSafeRedirectPath) only checked startsWith('/') and !startsWith('//') but accepted auth pages like /login, /signup, /forgot-password, /reset-password, /auth/callback — added an AUTH_PATHS blocklist that rejects these as redirect targets
Nesting of redirectTo query params caused encoding amplification on each hop — added query string stripping when a redirect target contains its own ?redirectTo= param
Additionally, added a WEB_LOGIN_URL guard in the dashboard that detects when VITE_APP_URL resolves to the dashboard's own origin (port 5174) instead of the web app (port 5173), preventing self-referencing navigation that causes an infinite page reload.
Summary by CodeRabbit
New Features
Bug Fixes