Add support for multi-tenancy in reactJS app

Hi there,
I have developed a web app using reactJS for the frontend, nodeJS for the backend and Auth0 for authentication. I want to support multi-tenancy in my app such that a single login screen can redirect the user to their respective URLs depending upon their app_metadata .
The metadata has the redirect URL and I’m successfully able to access the metadata. The problem that I’m facing is that my react app is getting stuck in an infinite loop of redirects from the home page (after logging in) and the auth0’s login flow.
Since the redirect URL is a completely URL (subdomain of our domain) I’m trying to redirect to that URL using window.open(redirect_url) and window.location.replace(redirect_url) .

Hi @ksoni,

Thanks for your question.

For multi-tenancy, we recommend using Auth0 Organizations.

This approach avoids the burden of handling all the delicate redirect URLs and subdomains by representing each tenant as an organization. It also allows users who belong to different organizations to log in through a single login page. Then, if you need to redirect them further, you could use a post-login action to redirect these users.

Let me know if you have any follow-up questions.

Kind regards,
Rueben

1 Like