diff --git a/src/middleware.ts b/src/middleware.ts index e1eab93..40be513 100644 --- a/src/middleware.ts +++ b/src/middleware.ts @@ -13,15 +13,11 @@ export function middleware(req: NextRequest) { const host = req.headers.get("host") || ""; const tenantPath = HOST_MAP[host.toLowerCase()] || ""; - console.log("[middleware] host:", host, "| tenantPath:", tenantPath || "(none)"); - if (!tenantPath) { - console.log("[middleware] → next() (no tenant for host)"); return NextResponse.next(); } const pathname = req.nextUrl.pathname; - console.log("[middleware] pathname:", pathname); // مسیرهای api و استاتیک را rewrite نکن if ( @@ -29,7 +25,6 @@ export function middleware(req: NextRequest) { pathname.startsWith("/_next") || pathname.includes(".") ) { - console.log("[middleware] → next() (api/static path)"); return NextResponse.next(); } @@ -37,19 +32,16 @@ export function middleware(req: NextRequest) { if (pathname === "/") { const url = req.nextUrl.clone(); url.pathname = tenantPath; - console.log("[middleware] → redirect to:", url.pathname); return NextResponse.redirect(url); } // اگر مسیر از قبل با tenant یکی است (مثلاً /passata یا /passata/menu)، rewrite نکن if (pathname === tenantPath || pathname.startsWith(tenantPath + "/")) { - console.log("[middleware] → next() (path already has tenant)"); return NextResponse.next(); } const url = req.nextUrl.clone(); url.pathname = `${tenantPath}${pathname}`; - console.log("[middleware] → rewrite to:", url.pathname); return NextResponse.rewrite(url); }