Vercel.app for previews

Hi, I'm using BetterAuth in production across two different subdomains: api.example.com (where BetterAuth is hosted) and site.example.com (I've configured cookiesubdomain, etc.). Everything works perfectly in production, and I'm hosting with Vercel. However, when I create new branches or run tests, Vercel assigns preview domains under .vercel.app, and at that point authentication stops working. Is there a way to make authentication work correctly on these Vercel preview domains as well? Do you have any suggestions or best practices for handling this? Thanks in advance!
4 Replies
KiNFiSH
KiNFiSH4mo ago
you can use VERCEL_URL which is default env setting on vercel for baseUrl
bitangel84
bitangel84OP4mo ago
?? What about the cookie configuration? There is no issue with the baseUrl, the issue is with the cookie
KiNFiSH
KiNFiSH4mo ago
give me your auth config you mean this one -
crossSubDomainCookies: {
enabled: true,
domain: ".example.com",
},
crossSubDomainCookies: {
enabled: true,
domain: ".example.com",
},
alex (he/him)
alex (he/him)4mo ago
I'm having a similar issue with Cloudflare. How did you solve this?

Did you find this page helpful?