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

Function isDocumentRequest

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

Source from the content-addressed store, hash-verified

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

Callers 1

ssr-gate.tsFile · 0.85

Calls 1

getMethod · 0.65

Tested by

no test coverage detected