Redirect after Logout in React SPA
Last Updated:
Overview
There is a single page application (SPA) in React where the following logout function is used:
logout({
logoutParams: {
returnTo: window.location.origin
}
})
There are also two allowed Logout URLs configured:
The issue seems to be that, no matter what environment is used when doing the redirect, it is not redirecting to "window.location.origin" but is redirecting to the first URL in the list.
Applies To
- Logout Redirect
- React single page application (SPA)
Solution
const logoutWithRedirect = () =>
logout({
returnTo: window.location.origin,
});