Multi-tenancy redirect issue on client-side nextjs

157 Views Asked by At

I am working on multi-tenancy feature for our white label apps in NextJS.

Each white label app will have a subdomain for example (apple.abc.org, samsung.abc.org). In the middleware, based on the subdomain I need to redirect it to a single page.

I am referring following example from vercel. https://github.com/vercel/examples/tree/main/edge-middleware/hostname-rewrites

/pages/index.js (also the app) is already configured to render content based on a certain tenant.

Middleware redirect me to /pages/_sites/[site]/index.tsx this is where I can fetch the data for the tenant specific config. (either on server side (recommended) or on client side and push it to /pages/index.js page).

The issue here is, the conflict between /pages/_sites/[site]/index.tsx and /pages/index.js

So when I try to push to '/' route, it doesn't gets redirected to /pages/index.js instead it remains on /pages/_sites/[site]/index.tsx

0

There are 0 best solutions below