import { NextResponse } from "next/server"; import type { NextRequest } from "next/server"; import { SERVER_SIDE_ONLY__PAID_ENTERPRISE_FEATURES_ENABLED, SERVER_SIDE_ONLY__AUTH_COOKIE_NAME, } from "./lib/constants"; // Route prefixes that never allow anonymous access, so we fast-fail at the edge // when no auth cookie is present. "/app" is intentionally excluded: it allows // anonymous access via a runtime (Redis-backed) setting the edge can't read from // cookies, so it's gated server-side by requireAuth() in // web/src/app/app/layout.tsx instead. const PROTECTED_ROUTES = ["/admin", "/agents", "/connector"]; // Public route prefixes (no authentication required) const PUBLIC_ROUTES = ["/auth", "/anonymous", "/_next", "/api"]; // The CSP is emitted here, not in next.config.js `headers()` (which is baked // into the build), so WEB_FRAME_PROTECTION_ENABLED is read at runtime and // applies on restart without a rebuild. // // frame-ancestors controls who may embed Onyx in an