Auth not working across completely different domains (app)

I'm trying to set up authentication where users log in on one domain and use the app on another completely different domain (think
auth-service.com
and
my-app.io
  • totally unrelated domains).
My setup:*
  • Auth server on
    a.xyz
  • Main app on
    foo.abc
  • Both use the same Turso database and identical Better-Auth configs
  • Same session table, same cookie names, everything
What happens:
  1. User logs in on auth server → works fine, session created in database
  2. Auth server sends session token back to main app
  3. Main app sets the token as a cookie on its domain
  4. When I call
    getSession()
    on the main app → returns null every time
I can see the session in the database and the cookie is set correctly, but Better-Auth just won't recognize it.

My question: Does Better-Auth tie sessions to the domain where they were created? Even with a shared database, will a session created on
a.xyz
never work on
foo.abc
?

I'm using SvelteKit + Better-Auth + Drizzle + Turso. Has anyone got this working with completely different domains?

All other config are normal or same as installation docs.

I may be missing something very obvious here, help would be really appreciated

Thanks!
Was this page helpful?