# returnTo Url is not working in react sdk

**URL:** <https://community.auth0.com/t/returnto-url-is-not-working-in-react-sdk/147017>\
**Category:** Get Help\
**Tags:** new-universal-login-experience, login-experience\
**Created:** [September 15, 2024, 9:16pm UTC](https://community.auth0.com/t/returnto-url-is-not-working-in-react-sdk/147017 "2024-09-15T21:16:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sagatheretro](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/sagatheretro/32/59898_2.png) [@sagatheretro](https://community.auth0.com/u/sagatheretro)\
**Post date:** [September 15, 2024, 9:16pm UTC](https://community.auth0.com/t/returnto-url-is-not-working-in-react-sdk/147017/1 "2024-09-15T21:16:43Z")

</div>

My Logout Button,

```auto
const LogoutBtn = () => {
  const {
    isAuthenticated,
    logout,
  } = useAuth0();

  const handleLogout = () => {
    const returnToUrl = window.location.origin || 'https://weplaydos.games';
    console.log('Logging out, returnTo:', returnToUrl);
    logout({ returnTo: returnToUrl });
  };

  return isAuthenticated && (
    <Button
      renderIcon={Logout}
      kind='ghost'
      onClick={handleLogout}>
      Log out
    </Button>
  );
}

```

It is being passed from the sdk but when I check the network tab, I see this url - https://dev-y27lxavr02scmif8.us.auth0.com/v2/logout?client\_id=jclY1uHk29dMQCtQqkRPUlJI2Cd5mRwA&auth0Client=eyJuYW1lIjoiYXV0aDAtcmVhY3QiLCJ2ZXJzaW9uIjoiMi4yLjQifQ%3D%3D

Can anyone help?

---

<div class="post-metadata">

**Author:** ![sagatheretro](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/sagatheretro/32/59898_2.png) [@sagatheretro](https://community.auth0.com/u/sagatheretro)\
**Post date:** [September 15, 2024, 9:19pm UTC](https://community.auth0.com/t/returnto-url-is-not-working-in-react-sdk/147017/2 "2024-09-15T21:19:22Z")

</div>

I am using a single application in 2 domains. And I have configured the logout urls on application level and also at the global level. Would really appreciate the help.

---

<div class="post-metadata">

**Author:** ![sagatheretro](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/sagatheretro/32/59898_2.png) [@sagatheretro](https://community.auth0.com/u/sagatheretro)\
**Post date:** [September 15, 2024, 9:20pm UTC](https://community.auth0.com/t/returnto-url-is-not-working-in-react-sdk/147017/3 "2024-09-15T21:20:20Z")

</div>

Login and redirection is working absolutely fine. It is just the Logout. It redirects the user to the other domain that is configured which is because of the missing returnTo param.

---

<div class="post-metadata">

**Author:** ![sagatheretro](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/sagatheretro/32/59898_2.png) [@sagatheretro](https://community.auth0.com/u/sagatheretro)\
**Post date:** [September 15, 2024, 9:34pm UTC](https://community.auth0.com/t/returnto-url-is-not-working-in-react-sdk/147017/4 "2024-09-15T21:34:28Z")

</div>

> [@Logout always redirects to first url from Allowed Logout URLs](https://community.auth0.com/t/logout-always-redirects-to-first-url-from-allowed-logout-urls/121719):
>
> I have a React application, and whenever I do logout, it always redirects to first URL from “Allowed Logout URLs” even though, I have specified the returnTo in my provider. Here’s the code for my provider: \<Auth0Provider domain="\<My domain here\>" clientId="\<My clientId here\>" authorizationParams={{ redirect\_uri: window.location.origin + window.location.pathname, audience: '\<My audience here\>', scope: 'openid pr…

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [September 29, 2024, 9:34pm UTC](https://community.auth0.com/t/returnto-url-is-not-working-in-react-sdk/147017/5 "2024-09-29T21:34:43Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
