Unable to log in to prod branch main after using PR based workflow

I was eager to try out this feature but may have done something wrong along the way. I use next-auth in this Next.js project on Vercel. I have the Vercel integration aswell. I can log in to the site as a user on the preview branch, but now my users and me can't log in the prod site on main. Any suggestions?
No description
3 Replies
๐Ÿ†‚๐Ÿ…ต๐Ÿ…ฒ SPACEFLAKE
This is the error i got from the callback. No branch was passed to the client constructor. Using default branch main. You can set the branch with the environment variable XATA_BRANCH or by passing the branch option to the client constructor. [next-auth][error][OAUTH_CALLBACK_ERROR] https://next-auth.js.org/errors#oauth_callback_error State cookie was missing. { error: TypeError: State cookie was missing. at Object.use (/var/task/node_modules/next-auth/core/lib/oauth/checks.js:111:23) at oAuthCallback (/var/task/node_modules/next-auth/core/lib/oauth/callback.js:89:25) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async Object.callback (/var/task/node_modules/next-auth/core/routes/callback.js:52:11) at async AuthHandler (/var/task/node_modules/next-auth/core/index.js:208:28) at async NextAuthApiHandler (/var/task/node_modules/next-auth/next/index.js:22:19) at async NextAuth._args$ (/var/task/node_modules/next-auth/next/index.js:108:14) at async K (/var/task/node_modules/next/dist/compiled/next-server/pages-api.runtime.prod.js:20:16853) at async U.render (/var/task/node_modules/next/dist/compiled/next-server/pages-api.runtime.prod.js:20:17492) at async r3.runApi (/var/task/node_modules/next/dist/compiled/next-server/server.runtime.prod.js:17:43997) { name: 'OAuthCallbackError', code: undefined }, providerId: 'discord', message: 'State cookie was missing.' } What am I missing?
Errors | NextAuth.js
This is a list of errors output from NextAuth.js.
kostas
kostasโ€ข4mo ago
Hi, when connecting the Xata Vercel integration to a project on Vercel, it sets up some Environment Variables (XATA_API_KEY, XATA_PREVIEW, XATA_DATABASE_URL).
A new XATA_API_KEY is automatically generated every time you connect the integration (you will find it in your Account's API keys list). The XATA_DATABASE_URL is that of the connected database. The XATA_PREVIEW env variable instructs the Xata client to automatically connect with the dynamically generated Xata "preview-yourdevbranch" branch instead of an explicitly specified target branch in Preview environments. For your production environment you'll additionally need to set the XATA_BRANCH env variable to instruct it to connect to main (or whichever branch you use in production). Check if that is set up in the Production environment on Vercel in Settings -> Environment Variables -> Production environment list.
๐Ÿ†‚๐Ÿ…ต๐Ÿ…ฒ SPACEFLAKE
Yes. Thank you @kostas โค๏ธ. I suspected it was something with the env variables. I didnยดt quite understand how it was set up. Now it works as expected.
Want results from more Discord servers?
Add your server