Spaces:
Running
Running
add log
Browse files- 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 |
-
|
|
|
|
| 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);
|