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

Function proxyToVite

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

Source from the content-addressed store, hash-verified

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

Callers 1

fetchFunction · 0.85

Calls 3

setMethod · 0.80
fetchFunction · 0.70
deleteMethod · 0.65

Tested by

no test coverage detected