From 75773039b63f4748584edc13e6bb70f96ab64665 Mon Sep 17 00:00:00 2001 From: Erik van Velzen Date: Thu, 15 Feb 2024 15:19:40 +0100 Subject: [PATCH] Fix react example redirect The react example didn't work if you configured the UI to be on the different (sub)domain or port than the Ory Tunnel. --- examples/react-spa/src/sdk.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/examples/react-spa/src/sdk.ts b/examples/react-spa/src/sdk.ts index 03ece6911..171e58e8e 100644 --- a/examples/react-spa/src/sdk.ts +++ b/examples/react-spa/src/sdk.ts @@ -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, ) @@ -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() }