thankful-toddler-79861
12/29/2022, 4:12 PMFailed to load resource: the server responded with a status of 403 (Forbidden)
<http://localhost:4000/ui/error?id=MY_ID>
Here is the code (ReactJS)
In my app root component:
useEffect(() => {
Ory.toSession()
.then(({ data }) => {
Ory.createBrowserLogoutFlow().then(({ data: logoutFlow }) => {
//Global State
setSession(data);
setLogoutUrl(logoutFlow.logout_url);
})
})
.catch((err) => {
console.error(err);
// Redirect to login page
window.location.replace(`${basePath}/ui/login`);
});
},[]);
This piece of code works, I successfully set the session and logout url in global state
Then in a nested component where I render a button for logging out, I call this function consuming the logout URL from the global state:
const handleLogout = async () => {
try {
// Use the recieved token to "update" the flow and thus perform the logout
await Ory.updateLogoutFlow({
token: applicationStore.logoutUrl!,
}).then(() => {
// .. some logic to remove the session & logout URL from global state
});
} catch (error) {
...
}
};
The Ory Tunnel is running too, and working for the sign in and sign up flows
I'm really not sure how to fix this, does anyone knows ?
Seems like Ory Network forbids my frontend from calling the logout URL for some reasonsgentle-thailand-50068
12/29/2022, 5:30 PMlogout_url
to logout instead of using the url as a token.
Please have a look at this example: https://www.ory.sh/docs/getting-started/integrate-auth/react#require-login-to-access-the-app-pagethankful-toddler-79861
12/29/2022, 8:17 PM