Skip to content

Commit

Permalink
fix: react example redirect
Browse files Browse the repository at this point in the history
The react example didn't work if you configured the UI to be on the
different (sub)domain or port than the Ory Tunnel.
  • Loading branch information
Erikvv committed Feb 15, 2024
1 parent a24fc14 commit 0907a79
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions examples/react-spa/src/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export const sdkError = (
const currentUrl = new URL(window.location.href)
const redirect = new URL(
responseData.redirect_browser_to,
// need to add the base url since the `redirect_browser_to` is a relative url with no hostname
// need to add the base url since the `redirect_browser_to` may be a relative url with no hostname
window.location.origin,
)

Expand All @@ -132,9 +132,7 @@ export const sdkError = (
// remove /ui prefix from the path in case it is present (not setup correctly inside the project config)
// since this is an SPA we don't need to redirect to the Account Experience.
redirect.pathname = redirect.pathname.replace("/ui", "")
navigate(redirect.pathname + redirect.search, {
replace: true,
})
window.location.assign(redirect.toString())
return Promise.resolve()
}

Expand Down

0 comments on commit 0907a79

Please sign in to comment.