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

Function proxyToVite

apps/local/src/serve.ts:225–242  ·  view source on GitHub ↗
(req: Request, viteUrl: string)

Source from the content-addressed store, hash-verified

223}
224
225async function proxyToVite(req: Request, viteUrl: string): Promise<Response> {
226 const target = new URL(req.url);
227 target.protocol = "http:";
228 target.host = new URL(viteUrl).host;
229 // Strip hop-by-hop headers that confuse the upstream
230 const headers = new Headers(req.headers);
231 headers.delete("host");
232 headers.set("host", target.host);
233 const hasBody = req.method !== "GET" && req.method !== "HEAD";
234 return fetch(target, {
235 method: req.method,
236 headers,
237 body: hasBody ? req.body : undefined,
238 redirect: "manual",
239 // @ts-expect-error — Bun/undici extension required for streamed bodies
240 duplex: hasBody ? "half" : undefined,
241 });
242}
243
244// ---------------------------------------------------------------------------
245// Server

Callers 1

fetchFunction · 0.85

Calls 3

fetchFunction · 0.70
deleteMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected