Hey folks :wave: I'm currently implementing Ory N...
# ory-network
t
Hey folks 👋 I'm currently implementing Ory Network in my project, but I can't find the reason why the logout flow doesn't work The sign in / sign up flows work perfectly, when when I try to logout, I get the following error:
Copy code
Failed 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:
Copy code
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:
Copy code
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 reasons
g
You have to open the
logout_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-page
t
As simple as this, thanks @gentle-thailand-50068