Next.js Discord

Discord Forum

Is it possible to rewrite the root source and not only the path that comes after?

Unanswered
Grass carp posted this in #help-forum
Open in Discord
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):

async rewrites() { return [ { source: '/:path*', missing: [ { type: 'host', value: 'original-url.com', }, ], destination: '/tenant-specific-route/', }, ]; }
Does anyone have any idea?

1 Reply