Skip to content

Commit 2b1df21

Browse files
committed
fix: prevent double /admin prefix on admin subdomain
1 parent 9d4fb79 commit 2b1df21

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

web/src/middleware.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ export default clerkMiddleware(async (auth, req) => {
1414
// 1. Admin Subdomain Logic
1515
// Check for "admin." prefix (works for admin.saileelarahasya.com and admin.localhost)
1616
if (hostname.startsWith("admin.")) {
17+
// If already on /admin path, don't double-prefix
18+
if (url.pathname.startsWith('/admin')) {
19+
return NextResponse.next();
20+
}
1721
// Rewrite all requests to the /admin path (which maps to src/app/admin)
1822
return NextResponse.rewrite(new URL(`/admin${path}`, req.url));
1923
}

0 commit comments

Comments
 (0)