Skip to content

fix: improve URL validation in signOut redirect logic#21

Merged
nicknisi merged 1 commit intoworkos:mainfrom
Esper-Labs:signOut
Dec 10, 2025
Merged

fix: improve URL validation in signOut redirect logic#21
nicknisi merged 1 commit intoworkos:mainfrom
Esper-Labs:signOut

Conversation

@rgcottrell
Copy link
Contributor

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
Copy link
Member

@nicknisi nicknisi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@nicknisi nicknisi merged commit 21a2f5d into workos:main Dec 10, 2025
4 checks passed
@nicknisi nicknisi mentioned this pull request Dec 15, 2025
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

2 participants