I am trying to create a simple/sample NextJs app with OAuth login
I downloaded the code provided by the dashboard whilst creating firs sample APP using NextJs
I configured and copied environment variables mentioned exactly in https://auth0.com/docs/quickstart/webapp/nextjs/interactive
article.
I ran npm install
npm run dev
and started the app.
my NextJs Application uses pages
directory and /api/auth/[auth0].ts
, api handler is simply
import {handleAuth} from “@auth0/nextjs-auth0”;
export default handleAuth();
when I click Login, I get redirected to Auth0 screen for signin/SignUp.
It then redirects me to my application on
with following error on nextJs Server console!!
CallbackHandlerError: Callback handler failed. CAUSE: Missing state cookie from login request (check login URL, callback URL and cookie config).
at CallbackHandlerError.AuthError [as constructor] (/Users/hiteshkhatri/Documents/BMI/next-auth0-3/node_modules/@auth0/nextjs-auth0/dist/utils/errors.js:34:16)
at CallbackHandlerError.HandlerError [as constructor] (/Users/hiteshkhatri/Documents/BMI/next-auth0-3/node_modules/@auth0/nextjs-auth0/dist/utils/errors.js:110:23)
at new CallbackHandlerError (/Users/hiteshkhatri/Documents/BMI/next-auth0-3/node_modules/@auth0/nextjs-auth0/dist/utils/errors.js:138:28)
at /Users/hiteshkhatri/Documents/BMI/next-auth0-3/node_modules/@auth0/nextjs-auth0/dist/handlers/callback.js:42:31
at step (/Users/hiteshkhatri/Documents/BMI/next-auth0-3/node_modules/tslib/tslib.js:195:27)
at Object.throw (/Users/hiteshkhatri/Documents/BMI/next-auth0-3/node_modules/tslib/tslib.js:176:57)
at rejected (/Users/hiteshkhatri/Documents/BMI/next-auth0-3/node_modules/tslib/tslib.js:167:69)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
code: ‘ERR_CALLBACK_HANDLER_FAILURE’,
cause: MissingStateCookieError: Missing state cookie from login request (check login URL, callback URL and cookie config).
at new MissingStateCookieError (/Users/hiteshkhatri/Documents/BMI/next-auth0-3/node_modules/@auth0/nextjs-auth0/dist/auth0-session/utils/errors.js:39:16)
at /Users/hiteshkhatri/Documents/BMI/next-auth0-3/node_modules/@auth0/nextjs-auth0/dist/auth0-session/handlers/callback.js:30:63
at step (/Users/hiteshkhatri/Documents/BMI/next-auth0-3/node_modules/tslib/tslib.js:195:27)
at Object.next (/Users/hiteshkhatri/Documents/BMI/next-auth0-3/node_modules/tslib/tslib.js:176:57)
at fulfilled (/Users/hiteshkhatri/Documents/BMI/next-auth0-3/node_modules/tslib/tslib.js:166:62)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
expose: true,
statusCode: 400,
status: 400
},
status: 400
}
I have tried to upgrade / downgrade Auth0 version(s) …but nothing works!!
This topic has been discussed here multiple times … but everyone’s causes seems to be different!