Skip to content

Conversation

@rgcottrell
Copy link

Replace simple string-based URL checking with proper URL parsing using the URL constructor. This provides more robust validation of internal vs external redirects during the sign-out flow.

The previous approach checked if the location started with 'http' and didn't contain the current host, which could fail for edge cases like relative URLs or malformed URLs. The new implementation:

  • Uses URL constructor to properly parse redirect locations
  • Handles relative paths with try/catch fallback
  • More accurately distinguishes between same-origin and cross-origin redirects

This ensures TanStack Router navigation is used for internal routes while full page navigation is used for external OAuth/logout URLs.

Fixes #19

Replace simple string-based URL checking with proper URL parsing
using the URL constructor. This provides more robust validation of
internal vs external redirects during the sign-out flow.

The previous approach checked if the location started with 'http'
and didn't contain the current host, which could fail for edge cases
like relative URLs or malformed URLs. The new implementation:
- Uses URL constructor to properly parse redirect locations
- Handles relative paths with try/catch fallback
- More accurately distinguishes between same-origin and cross-origin
  redirects

This ensures TanStack Router navigation is used for internal routes
while full page navigation is used for external OAuth/logout URLs.

Fixes workos#19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

signOut({ returnTo }) uses client-side navigation instead of full page load

1 participant