enzostvs HF Staff commited on
Commit
404f370
·
1 Parent(s): bdde20c
Files changed (1) hide show
  1. middleware.ts +4 -1
middleware.ts CHANGED
@@ -6,8 +6,11 @@ export function middleware(request: NextRequest) {
6
  const isLocalDev = hostname === "localhost" || hostname === "127.0.0.1" || hostname.startsWith("192.168.");
7
  const isHuggingFace = hostname === "huggingface.co" || hostname.endsWith(".huggingface.co");
8
 
 
 
9
  if (!isHuggingFace && !isLocalDev) {
10
- const canonicalUrl = new URL(request.nextUrl.pathname + request.nextUrl.search, "https://huggingface.co");
 
11
  canonicalUrl.pathname = request.nextUrl.pathname;
12
  canonicalUrl.search = request.nextUrl.search;
13
  return NextResponse.redirect(canonicalUrl, 301);
 
6
  const isLocalDev = hostname === "localhost" || hostname === "127.0.0.1" || hostname.startsWith("192.168.");
7
  const isHuggingFace = hostname === "huggingface.co" || hostname.endsWith(".huggingface.co");
8
 
9
+ console.log("[Middleware] hostname:", hostname, "isHuggingFace:", isHuggingFace, "isLocalDev:", isLocalDev);
10
+
11
  if (!isHuggingFace && !isLocalDev) {
12
+ console.log("[Middleware] Redirecting to huggingface.co");
13
+ const canonicalUrl = new URL("https://huggingface.co/deepsite");
14
  canonicalUrl.pathname = request.nextUrl.pathname;
15
  canonicalUrl.search = request.nextUrl.search;
16
  return NextResponse.redirect(canonicalUrl, 301);