Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ export async function middleware(request: NextRequest) {

// For the root path on a subdomain, rewrite to the subdomain page
if (pathname === '/') {
return NextResponse.rewrite(new URL(`/s/${subdomain}`, request.url));
const url = request.nextUrl.clone();
url.pathname = `/s/${subdomain}`;
return NextResponse.rewrite(url);
}
}

Expand All @@ -68,6 +70,6 @@ export const config = {
* 2. /_next (Next.js internals)
* 3. all root files inside /public (e.g. /favicon.ico)
*/
'/((?!api|_next|[\\w-]+\\.\\w+).*)'
]
'/((?!api|_next|[\\w-]+\\.\\w+).*)',
],
};