Spaces:
Runtime error
Runtime error
Download src/middleware.ts from dvijaykrishnan/vault-video-processor: direct link, hf CLI and curl.
- Browser
- Download file 741 Bytes
-
https://huggingface.co/spaces/dvijaykrishnan/vault-video-processor/resolve/main/src/middleware.ts
- Command line
-
hf download hf://spaces/dvijaykrishnan/vault-video-processor/src/middleware.ts
-
curl -L -o middleware.ts https://huggingface.co/spaces/dvijaykrishnan/vault-video-processor/resolve/main/src/middleware.ts
741 Bytes
| import { betterFetch } from "@better-fetch/fetch"; | |
| import type { Session } from "better-auth/types"; | |
| import { NextResponse, type NextRequest } from "next/server"; | |
| export default async function authMiddleware(request: NextRequest) { | |
| const { data: session } = await betterFetch<Session>( | |
| "/api/auth/get-session", | |
| { | |
| baseURL: request.nextUrl.origin, | |
| headers: { | |
| //get the cookie from the request | |
| cookie: request.headers.get("cookie") || "", | |
| }, | |
| }, | |
| ); | |
| if (!session) { | |
| return NextResponse.redirect(new URL("/login", request.url)); | |
| } | |
| return NextResponse.next(); | |
| } | |
| export const config = { | |
| matcher: ["/dashboard/:path*"], | |
| }; | |