Closed Ojself closed 1 year ago
Hi! @Ojself thanks, i'll take a look
Update: I tried to deploy the whole project to Netlify with success. The signup and signin works as expected over there. So this issue is Vercel specific.
@Ojself maybe it can be the next-auth
version? i deployed the full example to vercel and the credentials works fine
here you can take a look:
App Dir: https://next-auth-sanity-example.vercel.app/app/credentials Pages: https://next-auth-sanity-example.vercel.app/credentials
the example is using the latest next-auth version (4.20.1)
I tried upgrading the next-auth version and copy-paste the code from the snippets you posted above. The same issue occur, it works locally, but not in production.
I suspect it must be something with my code. As a last effort, I posted my env variables. Is the examples you posted above using the same variables, or am I missing something?
@Ojself do you have the "Automatically expose System Environment Variables" option enabled?
also after change the variables you do a redeploy? every platform change needs a new deploy to take effect and the most variables are set for production only, are you sure you don't see a preview?
if everything works fine on netlify and local, it looks more like a vercel config thing
Sorry I didn't respond to this sooner. Yes I am exposing System Environment Variables automatically. I tried to redeploy after changing them as well. The preview and deployed version is the same.
I ended up moving the whole project from Vercel to Netlify with success. I'm sure there's just a small config at Vercel in order to fix it, but I couldn't figure it out.
I'm using next-auth-sanity 1.4.8 and everything works great locally, but when deployed to Vercel, the signin doesn't work. My logic suggests that when a user signs up, he/she should be logged in after the user is created (the code is posted below).
The user get's created and can be found in the sanity data lake, but when it's time to sign in, the user get's redirected to https://www.domain-name.com/api/auth/error
I've been suggested to set both NEXTAUTH_URL and NEXTAUTH_SECRET in Vercel, but they already exist and didn't do any difference to the outcome.
From the network tab:
package.json:
signup/signin module
sanityClient.js
[...nextauth].js