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!
3 Replies
KiNFiSH
KiNFiSH2w ago
you can use VERCEL_URL which is default env setting on vercel for baseUrl
bitangel84
bitangel84OP7d ago
?? What about the cookie configuration? There is no issue with the baseUrl, the issue is with the cookie
KiNFiSH
KiNFiSH7d ago
give me your auth config you mean this one -
crossSubDomainCookies: {
enabled: true,
domain: ".example.com",
},
crossSubDomainCookies: {
enabled: true,
domain: ".example.com",
},

Did you find this page helpful?