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

Function buildDocsUpstream

apps/cloud/src/edge/docs.ts:26–41  ·  view source on GitHub ↗
(request: Request)

Source from the content-addressed store, hash-verified

24// guarantees `isDocsPath(pathname)` — we only swap the origin and fix up the
25// forwarding headers, preserving method, body, path, and query.
26export const buildDocsUpstream = (request: Request): Request => {
27 const url = new URL(request.url);
28 const forwardedHost = url.host;
29
30 url.hostname = DOCS_UPSTREAM_HOST;
31 url.protocol = "https:";
32 url.port = "";
33
34 const upstream = new Request(url, request);
35 // Mintlify keys canonical links off the public host; tell it the real one.
36 upstream.headers.set("X-Forwarded-Host", forwardedHost);
37 upstream.headers.set("X-Forwarded-Proto", "https");
38 // Never leak the executor.sh session cookie to the docs origin.
39 upstream.headers.delete("cookie");
40 return upstream;
41};
42
43export const docsProxyMiddleware = createMiddleware({ type: "request" }).server(
44 ({ pathname, request, next }) => {

Callers 2

upstreamForFunction · 0.90
docs.tsFile · 0.85

Calls 2

setMethod · 0.80
deleteMethod · 0.65

Tested by 1

upstreamForFunction · 0.72