# BadRequest: checks.state argument is missing auth0/nextjs

**URL:** <https://community.auth0.com/t/badrequest-checks-state-argument-is-missing-auth0-nextjs/61843>\
**Category:** Get Help\
**Tags:** callback, nextjs, auth0\
**Created:** [April 27, 2021, 2:21pm UTC](https://community.auth0.com/t/badrequest-checks-state-argument-is-missing-auth0-nextjs/61843 "2021-04-27T14:21:14Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![discrete.dev](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/discrete.dev/32/12809_2.png) [@discrete.dev](https://community.auth0.com/u/discrete.dev)\
**Post date:** [April 27, 2021, 2:21pm UTC](https://community.auth0.com/t/badrequest-checks-state-argument-is-missing-auth0-nextjs/61843/1 "2021-04-27T14:21:14Z")

</div>

Please include the following information in your post:

- **Which SDK this is regarding:** @auth0/nextjs-auth0
- **SDK Version:** 1.3.0
- **Platform Version:** next: 10.1.3, Node: 15.13.0
- **Code Snippets/Error Messages/Supporting Details/Screenshots:**  
BadRequest: checks.state argument is missing after login

After successfully login in via Google or Github (as shown in auth0 logs):

 ![image](https://global.discourse-cdn.com/auth0/original/3X/2/4/24f3e3e0c05c7a9caf0f31c4d15ca293d154db27.png)  
The nextjs api callback function of the SDK receives the request (which contains query params: code, state & auth0: [‘callback’]) but does not exchange the code for an access token (fails with 400 BadRequest ‘checks.state’ argument is missing). This only occurs when in production (I am using Netlify to deploy my NextJS web application) but not when using the localhost development enviroment. I checked all enviroment vars and they are the same for production and development (except URLs) and also verified that the auth0 app configuration (in dashboard) matches with the enviroment vars.

![image](https://global.discourse-cdn.com/auth0/original/3X/d/a/da088b63198fdbe86b11d279f8e107a5e1d91c89.png)

---

<div class="post-metadata">

**Author:** ![zaarheed](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/zaarheed/32/28271_2.png) [@zaarheed](https://community.auth0.com/u/zaarheed)\
**Post date:** [April 28, 2021, 9:31pm UTC](https://community.auth0.com/t/badrequest-checks-state-argument-is-missing-auth0-nextjs/61843/2 "2021-04-28T21:31:30Z")

</div>

Same issue here. This has been working for me for about a month and all of a sudden I get this error now and all my client websites are down. No changes to the code…

---

<div class="post-metadata">

**Author:** ![zaarheed](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/zaarheed/32/28271_2.png) [@zaarheed](https://community.auth0.com/u/zaarheed)\
**Post date:** [April 28, 2021, 10:13pm UTC](https://community.auth0.com/t/badrequest-checks-state-argument-is-missing-auth0-nextjs/61843/3 "2021-04-28T22:13:39Z")

</div>

plot twist: I cant recreate this when my browser is in incognito

---

<div class="post-metadata">

**Author:** ![Breck37](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/breck37/32/27819_2.png) [@Breck37](https://community.auth0.com/u/Breck37)\
**Post date:** [April 29, 2021, 3:42am UTC](https://community.auth0.com/t/badrequest-checks-state-argument-is-missing-auth0-nextjs/61843/4 "2021-04-29T03:42:24Z")

</div>

I receive this error when trying to login via a github deployment preview url I get through Vercel. It works locally and in production but not on preview urls. I believe the issue to be related to my AUTH0\_BASE\_URL env variable along with the configuration in auth0.

For me, I would assume that the issue involves this env var being used for production on a preview url that isn’t the same domain but would love insight on to how this can be rectified.

For you others, my best advice would be to analyze the `redirect_uri` on the network request and confirm it is what it should be based on your specific environment as well as ensuring you have the correct env variable. I don’t know if that will help, just my guess based on my experience.

---

<div class="post-metadata">

**Author:** ![mmatur](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/mmatur/32/12765_2.png) [@mmatur](https://community.auth0.com/u/mmatur)\
**Post date:** [April 29, 2021, 2:01pm UTC](https://community.auth0.com/t/badrequest-checks-state-argument-is-missing-auth0-nextjs/61843/5 "2021-04-29T14:01:05Z")

</div>

Hi,

On our side we have encountered the same issue deploying on Netlify. We have tested to deploy on Vercel and in a Docker container an we don’t have the issue.

Do you think it something can be linked to Netlify?

---

<div class="post-metadata">

**Author:** ![mmatur](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/mmatur/32/12765_2.png) [@mmatur](https://community.auth0.com/u/mmatur)\
**Post date:** [April 30, 2021, 1:31pm UTC](https://community.auth0.com/t/badrequest-checks-state-argument-is-missing-auth0-nextjs/61843/6 "2021-04-30T13:31:08Z")

</div>

Seems to be related to [https://answers.netlify.com/t/bug-netlify-functions-event-headers-cookie-sometimes-suddenly-used-comma-instead-of-semicolon/36793/7](https://answers.netlify.com/t/bug-netlify-functions-event-headers-cookie-sometimes-suddenly-used-comma-instead-of-semicolon/36793/7)

They are working on a fix

---

<div class="post-metadata">

**Author:** ![a-rolland](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/a-rolland/32/29145_2.png) [@a-rolland](https://community.auth0.com/u/a-rolland)\
**Post date:** [May 26, 2021, 4:04pm UTC](https://community.auth0.com/t/badrequest-checks-state-argument-is-missing-auth0-nextjs/61843/7 "2021-05-26T16:04:58Z")

</div>

I there ! I posted a solution which worked for my specific case (Netlify + Nextjs + Auth0) on this thread : [BadRequestError: checks.state argument is missing - #17 by scotty.j.roberts](https://community.auth0.com/t/badrequesterror-checks-state-argument-is-missing/42609/17)

Hope it can help you !

---

<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:** [May 28, 2021, 9:05am UTC](https://community.auth0.com/t/badrequest-checks-state-argument-is-missing-auth0-nextjs/61843/8 "2021-05-28T09:05:25Z")

</div>

Thanks for sharing it with the rest of community!

---

<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:** [June 12, 2021, 9:06am UTC](https://community.auth0.com/t/badrequest-checks-state-argument-is-missing-auth0-nextjs/61843/9 "2021-06-12T09:06:12Z")

</div>

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