Hello everyone,
This is a problem I have been dealing with for a few days, I tried looking for existing answers but didn't find the exact fix unfortunately.
So, I have a project deployed with SST, it is setup as a monorepo and it has two packages, one with the server functions using lambda and the other has the frontend website (on NextJS).
I have set up the better-auth server to run on a lambda, on a dedicated domain. The website runs on the same domain (but are two different sub domains, so it's auth.domain.com and web.domain.com for example)
When deployed, the authentication works, I have enabled cross sub domain cookies and the flow works.
My problem currently is for development, since I'm using the default cookies behavior I am unable to call the auth lambda endpoint normally as it throws a CORS error, the frontend would need to be on the same domain as the auth server and the auth endpoint can't be on localhost as SST always assigns it a domain for live development.
What is the best approach here?
Is there a proven working solution here?
Thanks!!
Bruno