Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in Production on OAUTH callback #14

Open
harperaa opened this issue Aug 19, 2022 · 1 comment
Open

Error in Production on OAUTH callback #14

harperaa opened this issue Aug 19, 2022 · 1 comment

Comments

@harperaa
Copy link

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

image

Settings in Vercel Environment Variables:
NEXTAUTH_URL=https://code4rena-browser.vercel.app
GITHUB_CLIENT_ID
GITHUB_CLIENT_SECRET
NEXTAUTH_SECRET <set correctly using openssl rand -base64 32>

Settings on Github
image

I have scoured the internet, have seen some talking about this situation with nextauth, but I don't see an explanation or fix...

@harperaa
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant