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

Function originOf

apps/host-selfhost/src/auth/invalid-origin-help.ts:11–18  ·  view source on GitHub ↗
(request: Request)

Source from the content-addressed store, hash-verified

9
10/** The origin a request came from: the browser `Origin`, else the proxy host. */
11export const originOf = (request: Request): string | null => {
12 const explicit = request.headers.get("origin");
13 if (explicit) return explicit;
14 const host = request.headers.get("x-forwarded-host") ?? request.headers.get("host");
15 if (!host) return null;
16 const proto = request.headers.get("x-forwarded-proto") ?? "https";
17 return `${proto}://${host}`;
18};
19
20/** Actionable replacement for "Invalid origin". */
21export const invalidOriginHelp = (requestOrigin: string | null, webBaseUrl: string): string =>

Callers 2

rewriteInvalidOriginFunction · 0.85

Calls 1

getMethod · 0.65

Tested by

no test coverage detected