Spaces:
Running
Running
Download middleware.ts from Jacksuyu/demandsolution-codex: direct link, hf CLI and curl.
- Browser
- Download file 635 Bytes
-
https://huggingface.co/spaces/Jacksuyu/demandsolution-codex/resolve/main/middleware.ts
- Command line
-
hf download hf://spaces/Jacksuyu/demandsolution-codex/middleware.ts
-
curl -L -o middleware.ts https://huggingface.co/spaces/Jacksuyu/demandsolution-codex/resolve/main/middleware.ts
635 Bytes
| import { NextResponse } from "next/server"; | |
| import type { NextRequest } from "next/server"; | |
| export function middleware(request: NextRequest) { | |
| const response = NextResponse.next(); | |
| const anon = request.cookies.get("anon_id")?.value; | |
| if (!anon) { | |
| response.cookies.set("anon_id", crypto.randomUUID(), { | |
| httpOnly: true, | |
| sameSite: process.env.NODE_ENV === "production" ? "none" : "lax", | |
| secure: process.env.NODE_ENV === "production", | |
| path: "/", | |
| maxAge: 60 * 60 * 24 * 365, | |
| }); | |
| } | |
| return response; | |
| } | |
| export const config = { | |
| matcher: ["/((?!_next/static|_next/image|favicon.ico).*)"], | |
| }; | |