MCPcopy Create free account
hub / github.com/vercel/vercel / proxyPass

Function proxyPass

packages/cli/src/util/dev/server.ts:3158–3183  ·  view source on GitHub ↗

* Mimic nginx's `proxy_pass` for routes using a URL as `dest`.

(
  req: http.IncomingMessage,
  res: http.ServerResponse,
  dest: string,
  devServer: DevServer,
  requestId: string,
  ignorePath: boolean = true
)

Source from the content-addressed store, hash-verified

3156 * Mimic nginx's `proxy_pass` for routes using a URL as `dest`.
3157 */
3158function proxyPass(
3159 req: http.IncomingMessage,
3160 res: http.ServerResponse,
3161 dest: string,
3162 devServer: DevServer,
3163 requestId: string,
3164 ignorePath: boolean = true
3165): void {
3166 devServer.proxy.web(
3167 req,
3168 res,
3169 { target: dest, ignorePath },
3170 (error: NodeJS.ErrnoException) => {
3171 // response transforms for this request would never be applied
3172 // so clear the stored transforms
3173 devServer.clearResponseTransforms(req);
3174 // only debug output this error because it's always something generic like
3175 // "Error: socket hang up"
3176 // and the original error should have already been logged
3177 output.debug(`Failed to complete request to ${req.url}: ${error}`);
3178 if (!res.headersSent) {
3179 devServer.sendError(req, res, requestId, 'FUNCTION_INVOCATION_FAILED');
3180 }
3181 }
3182 );
3183}
3184
3185/**
3186 * Handle requests for static files with serve-handler.

Callers 2

delegateToServiceMethod · 0.85
DevServerClass · 0.85

Calls 3

debugMethod · 0.80
sendErrorMethod · 0.80

Tested by

no test coverage detected