import { NextResponse } from "next/server"; import type { NextRequest } from "next/server"; export function middleware(request: NextRequest) { const response = NextResponse.next(); if (!request.cookies.has("anon_id")) { const anonId = crypto.randomUUID(); response.cookies.set({ name: "anon_id", value: anonId, path: "/", httpOnly: true, secure: process.env.NODE_ENV === "production", sameSite: "lax", maxAge: 60 * 60 * 24 * 365, // 1 year }); } return response; } export const config = { matcher: ["/((?!_next/static|_next/image|favicon.ico).*)"], };