MCPcopy Index your code
hub / github.com/callstack/agent-device / forwardProxyRequest

Function forwardProxyRequest

src/remote/daemon-proxy.ts:104–124  ·  view source on GitHub ↗
(params: {
  req: IncomingMessage;
  res: ServerResponse;
  route: string;
  options: Required<DaemonProxyOptions>;
  rpcBody?: string;
})

Source from the content-addressed store, hash-verified

102}
103
104async function forwardProxyRequest(params: {
105 req: IncomingMessage;
106 res: ServerResponse;
107 route: string;
108 options: Required<DaemonProxyOptions>;
109 rpcBody?: string;
110}): Promise<void> {
111 const { req, res, route, options, rpcBody } = params;
112 const upstreamUrl = buildUpstreamUrl(options.upstreamBaseUrl, route, req.url ?? '/');
113 const method = req.method ?? 'GET';
114 const headers = buildUpstreamHeaders(req, options.upstreamToken, route);
115 const body = resolveUpstreamBody(req, route, rpcBody, options.upstreamToken);
116 const response = await options.fetchImpl(upstreamUrl, {
117 method,
118 headers,
119 signal: AbortSignal.timeout(options.upstreamTimeoutMs),
120 ...(body ? { body, duplex: 'half' as const } : {}),
121 });
122
123 await sendProxyResponse({ req, res, route, response, clientToken: options.clientToken });
124}
125
126async function sendProxyResponse(params: {
127 req: IncomingMessage;

Callers 1

handleProxyRequestFunction · 0.85

Calls 4

buildUpstreamUrlFunction · 0.85
buildUpstreamHeadersFunction · 0.85
resolveUpstreamBodyFunction · 0.85
sendProxyResponseFunction · 0.85

Tested by

no test coverage detected