Auth Subdomain

I'm working on a project which requires multiple subdomains within my site, many of which will need to access my auth cookies (think dashboard.*, admin.*). I was thinking putting my auth process on an auth.* route to standardize this configuration would be best, but I'm having a pretty hard time putting it together. I have tried using the advanced crossSubDomainCookies and trustedOrigins settings but am receiving CORS errors when trying to authenticate:

Access to fetch at 'http://localhost:3000/api/auth/get-session' from origin 'http://auth.localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

I created a minimal example repository (https://github.com/robskinney/better-auth-subdomain-example) of what I'm doing, I could really use some advice on this as I've been spinning my wheels. Thank you! 🍻
GitHub
Created to troubleshoot using an auth subdomain configuration with better-auth - robskinney/better-auth-subdomain-example
Was this page helpful?