# Invalid state after login

**URL:** <https://community.auth0.com/t/invalid-state-after-login/52051>\
**Category:** Get Help\
**Created:** [October 23, 2020, 8:40am UTC](https://community.auth0.com/t/invalid-state-after-login/52051 "2020-10-23T08:40:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![helloIAmPau](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/helloiampau/32/25124_2.png) [@helloIAmPau](https://community.auth0.com/u/helloIAmPau)\
**Post date:** [October 23, 2020, 8:40am UTC](https://community.auth0.com/t/invalid-state-after-login/52051/1 "2020-10-23T08:40:24Z")

</div>

Hello all. I’m trying to implement the authentication flow for my spa but I always receive an “invalid state” error on my callback page.

My application lives at “[https://app.local.io](https://app.local.io)” and my callback service lives at “[https://auth.local.io](https://auth.local.io)”.

here is how I configured my spa application:

 ![Screenshot 2020-10-23 at 10.34.59](https://global.discourse-cdn.com/auth0/original/3X/4/e/4eecaac8a1cab46db98b7357b044eb0cdf6571dd.png)

this is the authentication part of my app

```auto
    const getAuth = function() {
      if(_auth !== null) {
        return Promise.resolve(_auth);
      }

      return createAuth0Client({
        audience: config.audience,
        domain: config.domain,
        client_id: config.client_id
      }).then(function(auth) {
        _auth = auth;

        return auth;
      })
    };

      return getAuth().then(function(auth) {
        return Promise.all([auth.isAuthenticated(), auth]);
      }).then(function([isAuthenticated, auth]) {
        if(isAuthenticated === true) {
          return;
        }

        return auth.loginWithRedirect({
          redirect_uri: config.redirect_uri
        });
      });

```

and this is the relevant part of my callback page:

```auto
    createAuth0Client({
        audience: config.audience,
        domain: config.domain,
        client_id: config.client_id
      }).then(function(auth0) {
        return auth0.handleRedirectCallback();
      }).then(function() {
        var destination = window.location.origin.replace('auth', 'app');
        window.location.repalce(destination);
      });

```

it looks like it doesn’t set the auth0\_state cookie.

Is there something I’m missing in the configuration?

Thanks

---

<div class="post-metadata">

**Author:** ![jmangelo](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jmangelo/32/7923_2.png) [@jmangelo](https://community.auth0.com/u/jmangelo)\
**Post date:** [October 28, 2020, 5:07pm UTC](https://community.auth0.com/t/invalid-state-after-login/52051/2 "2020-10-28T17:07:36Z")

</div>

To my knowledge the SDK will set a cookie specific to the full domain where the SDK is being used, however, you’re using one domain to start the login and a different one to process the callback so it’s likely that the cookie is being set, but on `app.local.io` and as such unavailable once the response is returned to `auth.local.io`.

Can you expand on the use case for starting the login in one domain, but handling it in another one? Given they share a parent domain you can likely workaround this with custom logic, but that would seem unnecessary overhead.
