# State Mismatch issue with custom login screen and Auth0-js and NextJS

**URL:** <https://community.auth0.com/t/state-mismatch-issue-with-custom-login-screen-and-auth0-js-and-nextjs/86179>\
**Category:** Get Help\
**Created:** [June 29, 2022, 4:33pm UTC](https://community.auth0.com/t/state-mismatch-issue-with-custom-login-screen-and-auth0-js-and-nextjs/86179 "2022-06-29T16:33:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jacob.granberry](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jacob.granberry/32/35615_2.png) [@jacob.granberry](https://community.auth0.com/u/jacob.granberry)\
**Post date:** [June 29, 2022, 4:33pm UTC](https://community.auth0.com/t/state-mismatch-issue-with-custom-login-screen-and-auth0-js-and-nextjs/86179/1 "2022-06-29T16:33:56Z")

</div>

Please include the following information in your post:

- Which SDK this is regarding: nextjs-auth0
- SDK Version: 1.9.1
- Platform Version:
- Code Snippets/Error Messages/Supporting Details/Screenshots:

Her there - I’m attempting to wire up my app useing nextjs-auth0 SDK, and a custom universal login page that utilizes the auth0-js api to handle login etc. However, I am getting a state mismatch error when attempting to login, I believe because on the custom login page the `state` parameter is set in a query param and `nextjs-auth0` expect its on the cookie. Is there a way to resolve this?

---

<div class="post-metadata">

**Author:** ![jacob.granberry](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jacob.granberry/32/35615_2.png) [@jacob.granberry](https://community.auth0.com/u/jacob.granberry)\
**Post date:** [June 30, 2022, 12:06am UTC](https://community.auth0.com/t/state-mismatch-issue-with-custom-login-screen-and-auth0-js-and-nextjs/86179/2 "2022-06-30T00:06:13Z")

</div>

Figured it out! in my app, I was using initAuth0 with an audience and scope

```auto

  return initAuth0({
    baseURL: '...',
    issuerBaseURL: '...',
    secret: '...',
    clientID: '...',
    clientSecret: '...',
    routes: {
      callback: '/api/auth/callback',
      postLogoutRedirect: 'http://localhost:3000',
    },
    authorizationParams: {
      audience: ...,
      response_type: 'code',
      scope: 'openid profile email',
    },
  });

```

But in my hosted custom login screen in auth0, i was also initializing the WebAuth class with an audience and scope:

```auto
const webAuth = new WebAuth({
    overrides: {
      __tenant: config.auth0Tenant || tenant,
      __token_issuer: config.authorizationServer.issuer || serverIssuer,
    },
    domain: config.auth0Domain,
    clientID: config.clientID,
    audience: config.audience,
    scope: config.scope,
    redirectUri: config.callbackURL,
    responseType: 'code',
    ...config.internalOptions,
  });

```

Removing the audience and scope from the `new WebAuth` class successfully sent along the correct state back to my app

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [July 28, 2022, 1:25pm UTC](https://community.auth0.com/t/state-mismatch-issue-with-custom-login-screen-and-auth0-js-and-nextjs/86179/3 "2022-07-28T13:25:42Z")

</div>

Thanks for sharing that with the rest of community!

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [July 28, 2022, 1:25pm UTC](https://community.auth0.com/t/state-mismatch-issue-with-custom-login-screen-and-auth0-js-and-nextjs/86179/4 "2022-07-28T13:25:45Z")

</div>


