Make sure you have NEXTAUTH_URL correctly in your .env or any other corresponding enviroment file.
NEXTAUTH_URL
.env
For example if your are running in dev mode it could be http://localhost:3000 and in prod http://your-domain.com.
http://localhost:3000
http://your-domain.com