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

Function proxyToVite

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

Source from the content-addressed store, hash-verified

189}
190
191async function proxyToVite(req: Request, viteUrl: string): Promise<Response> {
192 const target = new URL(req.url);
193 target.protocol = "http:";
194 target.host = new URL(viteUrl).host;
195 // Strip hop-by-hop headers that confuse the upstream
196 const headers = new Headers(req.headers);
197 headers.delete("host");
198 headers.set("host", target.host);
199 const hasBody = req.method !== "GET" && req.method !== "HEAD";
200 return fetch(target, {
201 method: req.method,
202 headers,
203 body: hasBody ? req.body : undefined,
204 redirect: "manual",
205 // @ts-expect-error — Bun/undici extension required for streamed bodies
206 duplex: hasBody ? "half" : undefined,
207 });
208}
209
210// ---------------------------------------------------------------------------
211// Server

Callers 1

fetchFunction · 0.85

Calls 3

setMethod · 0.80
fetchFunction · 0.70
deleteMethod · 0.65

Tested by

no test coverage detected