enzostvs HF Staff commited on
Commit
7b4df73
·
1 Parent(s): 0cce1b7
Files changed (2) hide show
  1. app/layout.tsx +0 -3
  2. middleware.ts +4 -5
app/layout.tsx CHANGED
@@ -1,13 +1,10 @@
1
  /* eslint-disable @typescript-eslint/no-explicit-any */
2
  import type { Metadata, Viewport } from "next";
3
  import { Inter, PT_Sans } from "next/font/google";
4
- import { cookies } from "next/headers";
5
  import Script from "next/script";
6
 
7
  import "@/assets/globals.css";
8
  import { Toaster } from "@/components/ui/sonner";
9
- import MY_TOKEN_KEY from "@/lib/get-cookie-name";
10
- import { apiServer } from "@/lib/api";
11
  import IframeDetector from "@/components/iframe-detector";
12
  import AppContext from "@/components/contexts/app-context";
13
  import TanstackContext from "@/components/contexts/tanstack-query-context";
 
1
  /* eslint-disable @typescript-eslint/no-explicit-any */
2
  import type { Metadata, Viewport } from "next";
3
  import { Inter, PT_Sans } from "next/font/google";
 
4
  import Script from "next/script";
5
 
6
  import "@/assets/globals.css";
7
  import { Toaster } from "@/components/ui/sonner";
 
 
8
  import IframeDetector from "@/components/iframe-detector";
9
  import AppContext from "@/components/contexts/app-context";
10
  import TanstackContext from "@/components/contexts/tanstack-query-context";
middleware.ts CHANGED
@@ -4,12 +4,11 @@ import type { NextRequest } from "next/server";
4
  export function middleware(request: NextRequest) {
5
  const host = request.headers.get("host") || "";
6
 
7
- // Check if we're not on hf.co or huggingface.co
8
- const isHfCo = host === "hf.co" || host.startsWith("hf.co:");
9
- const isHuggingFaceCo = host === "huggingface.co" || host.startsWith("huggingface.co:");
10
 
11
- if (!isHfCo && !isHuggingFaceCo) {
12
- // Server-side redirect to the correct URL
13
  return NextResponse.redirect("https://huggingface.co/deepsite", 301);
14
  }
15
 
 
4
  export function middleware(request: NextRequest) {
5
  const host = request.headers.get("host") || "";
6
 
7
+ const isLocalhost = host.startsWith("localhost") || host.startsWith("127.0.0.1");
8
+ const isCorrectDomain = host === "huggingface.co" || host.startsWith("huggingface.co:");
 
9
 
10
+ console.log("++ DOMAIN CHECK ++", host)
11
+ if (!isCorrectDomain && !isLocalhost) {
12
  return NextResponse.redirect("https://huggingface.co/deepsite", 301);
13
  }
14