Using NextAuth.js with Netlify deploy-preview sites

Hi @SamO … thanks for the response… I tried clearing cache and even incognito, didn’t work.

Here is what I have tried.

  • Since according to the netlify docs, the url will be automatically set, I initially didn’t set an environment vars. Looking at the logs I noticed its being set already (Image included below).

  • Since I don’t know the preview url before hand, I followed the instructions here to use the netlify.toml file in setting it. Here is what the netlify.toml looks like

[context.production]
command = "yarn build && echo \"NEXTAUTH_URL=$URL\" > .env.local"

[context.deploy-preview]
command = "yarn build && echo \"NEXTAUTH_URL=$DEPLOY_PRIME_URL\" > .env.local"
  • I also manually set NEXTAUTH_URL as an environment variable to https://deploy-preview-21--weedle.netlify.app/ and rebuilt, still didn’t work.