Is it possible to rewrite the root source and not only the path that comes after?
Unanswered
Grass carp posted this in #help-forum
Grass carpOP
My app has tenants, and they will have their domains. The rewrite logic is if the host is not the original URL, rewrite it to the tenant-specific route.
However, I am unable to rewrite the root.
Failed rewrite:
tenantdomain.com -> will render default original-url.com/page.tsx
Successful rewrite:
tenantdomain.com/home -> will render tenantdomain.com/tenant-specific-route
Official documentation (will only work for path rewrite):
Does anyone have any idea?
However, I am unable to rewrite the root.
Failed rewrite:
tenantdomain.com -> will render default original-url.com/page.tsx
Successful rewrite:
tenantdomain.com/home -> will render tenantdomain.com/tenant-specific-route
Official documentation (will only work for path rewrite):
async rewrites() {
return [
{
source: '/:path*',
missing: [
{
type: 'host',
value: 'original-url.com',
},
],
destination: '/tenant-specific-route/',
},
];
}
Does anyone have any idea?
1 Reply
@Grass carp My app has tenants, and they will have their domains. The rewrite logic is if the host is not the original URL, rewrite it to the tenant-specific route.
However, I am unable to rewrite the root.
Failed rewrite:
tenantdomain.com -> will render default original-url.com/page.tsx
Successful rewrite:
tenantdomain.com/home -> will render tenantdomain.com/tenant-specific-route
Official documentation (will only work for path rewrite):
`async rewrites() {
return [
{
source: '/:path*',
missing: [
{
type: 'host',
value: 'original-url.com',
},
],
destination: '/tenant-specific-route/',
},
];
}`
Does anyone have any idea?
I know it’s not the optimal solution in this case but I’m using middleware for multi tenancy in prod and it works fine so you can perhaps try that