Cross sub domain session sharing
For anyone who plans on implementing cross sub domain cookies session save yourself the stress.
Here is the config I used to achieve this
- Setting cookies secure to "none" would not work on your localhost because it requires https except you manage to get wildcard ssl certificates for localhost
2 . If you want to test locally with the least friction in my experience just setup cloud flare tunnels i suggest getting a dedicated domain for dev. This means you now longer going to be using localhost instead yourdomain.com - don't forget to provide the wildcard *.yourdomain.com in the trusted origins config i.e better auth server instance
Here is the config I used to achieve this
advanced: { cookiePrefix: "yourprefix", crossSubDomainCookies: { enabled: true, domain: .yourdomain.com, }, }, trustedOrigins: [https://*.yourdomain.com], Cloudflare Docs
Cloudflare Tunnel provides you with a secure way to connect your resources to Cloudflare without a publicly routable IP address. With Tunnel, you do not send traffic to an external IP — instead, a lightweight daemon in your infrastructure (cloudflared) creates outbound-only connections to Cloudflare's global network. Cloudflare Tunnel can conn...
