mongodb-starter
mongodb-starter copied to clipboard
Error in Production on OAUTH callback
Hi, starter works well in dev, but when moving to production, ensuring correct callback in Github, and correct ID and Secret from Github in environment variables on Vercel, I keep getting an error when trying to authenticate.
Deployed site for confirmation here: https://code4rena-browser.vercel.app/
I have standard code base, fresh from git clone, no changes besides environment variables on Vercel.
I get this in the URL after trying to authenticate and after Github authorization: api/auth/signin?error=Callback

Settings in Vercel Environment Variables:
NEXTAUTH_URL=https://code4rena-browser.vercel.app
GITHUB_CLIENT_ID
Settings on Github
I have scoured the internet, have seen some talking about this situation with nextauth, but I don't see an explanation or fix...
Update, I found the problem, it was the mongodb uri, the one generated by the script was in this format (password masked): mongodb+srv://vercel-admin-user:***************@cluster0.nvhefxh.mongodb.net/admin
I had to change it to this format (obtained from mongodb atlas dashboard-connect settings) mongodb+srv://harperaa:*************@cluster0.mgwkzjj.mongodb.net/?retryWrites=true&w=majority
That solved it, so something is wrong with the vercel-mongo script. I also recommend you guys add some notes in the .env.local.example file, that lets users know to add the GITHUB_CLIENT_ID and GITHUB_CLIENT_SECRET and the NEXTAUTH_URL variables to the environment settings on vercel, after the initial build... or better yet, collect them in the build script, as it appears to do with NEXTAUTH_SECRET. That is not intuitive, for new users like me...
Anyway, it works now, thanks for starter... hope you can fix above so others can enjoy the package.