jatin
BABetter Auth
•Created by jatin on 3/20/2025 in #help
Issue with error redirection in case of a custom domain setup
I am building a no-code tool to build custom apps. Each app can have multiple users (email/pass based login). Each app is hosted on its own subdomain app1.domain1.com, app2.domain2.com, and so on.
When better-auth is used in a custom domain/multiple subdomain setup, the base URL is not known at build time but rather at runtime. When logging in via a social provider, let's say Google, if there is an error, the redirection is made to the baseURL defined in the context:
throw c.redirect(${c.context.baseURL}/error?error=state_not_found);
The ideal redirection should be to the client's subdomain. What is the best way to go about this?11 replies
BABetter Auth
•Created by jatin on 3/6/2025 in #help
Multi-tenant SaaS tool with multiple apps as tenants
Hello everyone. I am building a no-code tool to build custom apps. Each app can have multiple users (email/pass based login). Each app is hosted on its own subdomain app1.domain1.com, app2.domain2.com, and so on.
Essentially, in my case, every custom app is a tenant. An email address will be 2 different users segregated by the app_id. Is such a solution possible via better-auth?
Background Research
I did some research on multi-tenancy and could only figure out some kind of a hack where the slug of the organization could be the app_id. Essentially organization will be treated as an app. The organization terminology felt a little rigid but I want to see if I can make it work for my use case. There is also an open issue on Github with a similar requirement (https://github.com/better-auth/better-auth/issues/1248), but with no solutions.
7 replies