I have deployed my project to Vercel. The stack is a Turborepo monorepo with Next.js for the frontend and NestJS for the backend. For authentication, I’m using better-auth.
In production, the login request succeeds (I receive a successful response from the server), but the authentication cookie is not being set in the browser. Because of that, the user is not considered logged in after the request completes.
In my setup:
- Frontend and backend are deployed on different domains.
- Everything works correctly in local development.
- The issue only happens in production.
Has anyone experienced something similar?
Could this be related to:
- Cross-domain cookie settings?
- SameSite, Secure, or HttpOnly cookie configuration?
- CORS configuration between frontend and backend?
Any guidance would be greatly appreciated. Thank you!