diff --git a/src/components/ory/hooks.ts b/src/components/ory/hooks.ts index 3db811540..4c40baff0 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) => {