Spaces:
Paused
Paused
Download frontend/src/middleware.ts from data-llm-hub/tensorwall: direct link, hf CLI and curl.
- Browser
- Download file 837 Bytes
-
https://huggingface.co/spaces/data-llm-hub/tensorwall/resolve/main/frontend/src/middleware.ts
- Command line
-
hf download hf://spaces/data-llm-hub/tensorwall/frontend/src/middleware.ts
-
curl -L -o middleware.ts https://huggingface.co/spaces/data-llm-hub/tensorwall/resolve/main/frontend/src/middleware.ts
837 Bytes
| import { NextResponse } from 'next/server'; | |
| import type { NextRequest } from 'next/server'; | |
| export function middleware(request: NextRequest) { | |
| const { pathname } = request.nextUrl; | |
| // Check for access_token cookie (set after login) | |
| const hasToken = request.cookies.has('access_token'); | |
| // If accessing root without token, redirect to login (landing page) | |
| if (pathname === '/' && !hasToken) { | |
| return NextResponse.redirect(new URL('/login', request.url)); | |
| } | |
| // Allow all other routes | |
| return NextResponse.next(); | |
| } | |
| export const config = { | |
| matcher: [ | |
| /* | |
| * Match all request paths except for the ones starting with: | |
| * - _next/static (static files) | |
| * - _next/image (image optimization files) | |
| * - favicon.ico (favicon file) | |
| */ | |
| '/((?!_next/static|_next/image|favicon.ico).*)', | |
| ], | |
| }; | |