# Best practice for a redirection application (multi tenancy)

**URL:** <https://community.auth0.com/t/best-practice-for-a-redirection-application-multi-tenancy/181890>\
**Category:** Get Help\
**Tags:** new-universal-login-experience, login-experience\
**Created:** [February 10, 2025, 4:42pm UTC](https://community.auth0.com/t/best-practice-for-a-redirection-application-multi-tenancy/181890 "2025-02-10T16:42:53Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![lee.campbell](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/lee.campbell/32/72788_2.png) [@lee.campbell](https://community.auth0.com/u/lee.campbell)\
**Post date:** [February 10, 2025, 4:42pm UTC](https://community.auth0.com/t/best-practice-for-a-redirection-application-multi-tenancy/181890/1 "2025-02-10T16:42:53Z")

</div>

Hi,  
I’ve got a use case where users will navigate to a root domain `/`, but it doesn’t serve anything - it’s a small NextJS API proxy service. The service checks whether the user is authenticated (using the auth0-nextjs SDK), and has an Auth0 application configured. If the user is unauthenticated they are prompted to log in, on the return callback the service redirects the user to the appropriate subdirectory based on their Auth0 org role assignment. This all works fine.

The problem I’m having here is that each subdirectory is a NextJS service, with their own Auth0 application linked (again using the auth0-nextjs SDK). When the user logs into the root domain it sets a session cookie on the root path and the subdirectory cannot decrypt due it having its own AUTH0\_SECRET.

What’s the recommended practice here? I feel all the services sharing the same decryption env var AUTH0\_SECRET is wrong.

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [February 11, 2025, 1:30am UTC](https://community.auth0.com/t/best-practice-for-a-redirection-application-multi-tenancy/181890/3 "2025-02-11T01:30:25Z")

</div>

Hi @lee.campbell,

Welcome to the Auth0 Community!

In these types of use cases, we recommend a [Multiple Organization Architecture](https://auth0.com/docs/get-started/architecture-scenarios/multiple-organization-architecture). This way, you can use a single Auth0 tenant with separate applications to manage your user sessions.

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

Thanks,  
Rueben

---

<div class="post-metadata">

**Author:** ![lee.campbell](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/lee.campbell/32/72788_2.png) [@lee.campbell](https://community.auth0.com/u/lee.campbell)\
**Post date:** [February 13, 2025, 11:19am UTC](https://community.auth0.com/t/best-practice-for-a-redirection-application-multi-tenancy/181890/4 "2025-02-13T11:19:30Z")

</div>

Hi @rueben.tiow,

Thanks for the reply.

That’s the setup I have in place. The problem I’m having is that when users log into the universal application I rely on the Auth0 Organisation selector to determine which organisation they wish to access. On the auth callback from Auth0 this selection to the universal application I redirect the user the appropriate sub directory.

I.e. Tom has access to Tom’s Concrete Services & Tom’s Contracting. Tom logs into [app.example.com](http://app.example.com) (using Auth0 nextjs sdk) and the Auth0 Organisation selector shows the two organisations Tom has access to. Tom selects Tom’s Concrete Services, auth completes and the SDK behind [app.example.com](http://app.example.com) redirects Tom to [app.example.com/toms-concrete](http://app.example.com/toms-concrete) (using Auth0 nextjs sdk). This subdirectory is a root on another application, backed by another Auth0 application with organisation login enabled.

The problem here is that /toms-concrete can’t determine Tom is authenticated and shows the Auth0 login prompt again. I’m guessing this is down to /toms-concrete using a different AUTH0\_SECRET than [app.example.com](http://app.example.com). Thus, not being able to decrypt the auth session cookie and thinking Tom is unauthenticated.

What should I do here? Should [app.example.com](http://app.example.com) and the subdirectories share the same AUTH0\_SECRET env variable?

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [February 18, 2025, 6:41pm UTC](https://community.auth0.com/t/best-practice-for-a-redirection-application-multi-tenancy/181890/5 "2025-02-18T18:41:39Z")

</div>

Hi @lee.campbell,

Thanks for the reply.

Yes, sharing the AUTH0\_SECRET env variable is a valid approach, so your app can decrypt the auth session cookie.

However, to simplify authentication between your organizations, you could use a single Auth0 application instead of two separate applications. This way, you can have your application with Organizations enabled for both Tom’s Concrete Services and Tom’s Contracting, which allows the user to log in once and switch organizations within the same session.

During the login flow, when the user is prompted on the Organization selector page, they can choose whichever organization they prefer to log into. If, in the first login attempt, they chose Tom’s Concrete Services, and in the second attempt, they chose Tom’s Contracting, they wouldn’t be prompted to log in again because their session is active on the same app.

I hope this helps!

Best regards,  
Rueben

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [March 4, 2025, 6:41pm UTC](https://community.auth0.com/t/best-practice-for-a-redirection-application-multi-tenancy/181890/6 "2025-03-04T18:41:52Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
