NextJS App on AWS Amplify after login always get checks.state argument is missing

I used the Nextjs quick start and everything works fine on my local application and users can sign in as expected.

On AWS Amplify, things did not work as they did locally. I’ve gotten all of the ENV variables into the NodeJS environment (backend portion of the NextJS app) and this allows users to start the login flow, but then once they actually log in (social or username/pass) the application always shows the following error: checks.state argument is missing

Now, I looked into where in the auth flow it was getting hung up and found this:

This is the localhost version (that works) from the chrome network tab, and it shows setting the state cookie from the server after calling the /auth/login endpoint.

This is the AWS amplify hosted version, where the same exact request with the same code is not causing the server to set the state cookie.

No matter how many different browsers, incognito, or sessions I try I always get that same error.

Any ideas why this might be happening?


I have had this issue in the past and have been able to resolve it by confirming my Auth0 Base URL and callback URL are correct. However my most recent deployment is having the same issue and I have check all of the usual culprits 100x. Also using NextJS deployed through amplify. No idea what is going on here.

With some help from AWS we got this working, and a few things needed to be done to fix this issue. Hope this helps someone!

  1. Make sure your platform is set to WEB_DYNAMIC, since the WEB_COMPUTE platform (it’s a new one) appears to not be compatible yet with the Auth0 integration and fails with this error.
  2. Ensure that the nextjs version you’re using is set as a package version override on amplify setup in build image settings. Even if you have it set in your package.json file, you need to add it as an override to ensure the build uses the correct version.

Thanks a lot for sharing it with the rest of community!

I have switched to WEB_DYNAMIC and set the package version override and I am still getting the same issue. Was there anything else that needed to be changed?

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