MCPcopy Create free account
hub / github.com/Fibi66/FeiControl / proxyToInternal

Function proxyToInternal

scripts/dev-server.cjs:210–238  ·  view source on GitHub ↗
(request, response, host, port)

Source from the content-addressed store, hash-verified

208}
209
210function proxyToInternal(request, response, host, port) {
211 const proxyRequest = http.request(
212 {
213 hostname: host,
214 port,
215 path: request.url,
216 method: request.method,
217 headers: {
218 ...request.headers,
219 host: `${host}:${port}`,
220 },
221 },
222 (proxyResponse) => {
223 response.writeHead(proxyResponse.statusCode || 502, proxyResponse.headers);
224 proxyResponse.pipe(response);
225 }
226 );
227
228 proxyRequest.on('error', (error) => {
229 console.error('[dev-server] proxy request failed:', error);
230 if (!response.headersSent) {
231 response.statusCode = 502;
232 setNoStoreHeaders(response);
233 }
234 response.end('Bad Gateway');
235 });
236
237 request.pipe(proxyRequest);
238}
239
240async function main() {
241 const port = readArgValue(['--port', '-p']);

Callers 1

mainFunction · 0.85

Calls 1

setNoStoreHeadersFunction · 0.85

Tested by

no test coverage detected