From 47aeba7733379cff7bb670d99e225a5a0ccf3a89 Mon Sep 17 00:00:00 2001 From: Maina Wycliffe Date: Fri, 17 Nov 2023 19:22:56 +0300 Subject: [PATCH] fix: fix issue with return url --- src/components/ory/hooks.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/components/ory/hooks.ts b/src/components/ory/hooks.ts index 3db811540f..4c40baff0b 100644 --- a/src/components/ory/hooks.ts +++ b/src/components/ory/hooks.ts @@ -172,10 +172,13 @@ export function useCreateLogoutHandler(deps?: DependencyList) { const [logoutToken, setLogoutToken] = useState(""); const handleError = HandleError(); const { push } = useRouter(); + const returnTo = window.location.pathname + window.location.search; useEffect(() => { ory - .createBrowserLogoutFlow() + .createBrowserLogoutFlow({ + returnTo: returnTo + }) .then(({ data }) => { setLogoutToken(data.logout_token); }) @@ -187,7 +190,8 @@ export function useCreateLogoutHandler(deps?: DependencyList) { if (logoutToken) { ory .updateLogoutFlow({ - token: logoutToken + token: logoutToken, + returnTo: returnTo }) .then(() => push("/")) .catch((error) => {