feat: try to remove last slash

This commit is contained in:
DIYgod 2023-08-23 13:45:46 +01:00
parent 737b102d87
commit f8c6e509e6
No known key found for this signature in database
1 changed files with 6 additions and 2 deletions

View File

@ -106,13 +106,17 @@ export default async function middleware(req: NextRequest) {
if (tenant?.subdomain) {
console.debug(
`Rewrite to ${new URL(
`/site/${tenant?.subdomain}${pathname}${req.nextUrl.search}`,
`/site/${tenant?.subdomain}${pathname === "/" ? "" : pathname}${
req.nextUrl.search
}`,
req.url,
)}`,
)
return NextResponse.rewrite(
new URL(
`/site/${tenant?.subdomain}${pathname}${req.nextUrl.search}`,
`/site/${tenant?.subdomain}${pathname === "/" ? "" : pathname}${
req.nextUrl.search
}`,
req.url,
),
{