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

Function proxyToVite

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

Source from the content-addressed store, hash-verified

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

Callers 1

fetchFunction · 0.85

Calls 3

setMethod · 0.80
fetchFunction · 0.70
deleteMethod · 0.65

Tested by

no test coverage detected