Has anyone tried "hostname rewrites" in the app directory/multi-tenancy in the app dir?
Unanswered
Abyssinian posted this in #help-forum
AbyssinianOP
I’m looking to implement this pattern (https://vercel.com/templates/next.js/hostname-rewrites) to fix som multi-tenancy issues. We hope to move to RSC in the future and wanted to make sure doing this rewrite of the codebase is not going to require another massive one when moving to RSC. Anyone using this kind of pattern or another kind to do multi-tenancy with the app dir?
2 Replies
Gazami crab
Were you able to implement multi tenancy using the App Router then? Im required to do it for a project, not sure what are the differences vs the Pages Router
I'm attempting to do a very similar thing right now, and have got the bulk of it working - the only thing that doesnt work for me is redirecting the base of the subdomain to a nested page. For example I have:
I have rewrites setup to rewrite any request to
app/
layout.tsx
page.tsx ("home page")
[slug]/
page.tsx ("slug home page")
admin/
page.tsx ("admin page")I have rewrites setup to rewrite any request to
<slug>.example.com/:path* to example.com/<slug>/:path* and for the most part this works fine. Navigating to example.com loads the home page as expected, and navigating to test.example.com/admin loads the admin page with a slug param of test. The only thing that doesn't work is navigating to test.example.com - this just loads the normal home page and not the slug home page as I would expect