MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / isDocumentRequest

Function isDocumentRequest

apps/cloud/src/auth/doc-gate.ts:59–67  ·  view source on GitHub ↗
(request: Request)

Source from the content-addressed store, hash-verified

57const HINT_COOKIE_ATTRIBUTES = "Path=/; Secure; SameSite=Lax";
58
59const isDocumentRequest = (request: Request): boolean => {
60 if (request.method !== "GET" && request.method !== "HEAD") return false;
61 // Browsers label navigations explicitly; non-browser clients fall back to
62 // content negotiation. Anything that isn't asking for a page (vite module
63 // requests, JSON fetches, health probes) passes through ungated.
64 const dest = request.headers.get("sec-fetch-dest");
65 if (dest !== null) return dest === "document";
66 return request.headers.get("accept")?.includes("text/html") ?? false;
67};
68
69// Lazy for the same reason start.ts instantiates the app handler lazily: this
70// module reaches workers-only imports (cloudflare:workers via ./workos), which

Callers 1

doc-gate.tsFile · 0.85

Calls 1

getMethod · 0.65

Tested by

no test coverage detected