MCPcopy Index your code
hub / github.com/coder/code-server / getProxyTarget

Function getProxyTarget

src/node/routes/pathProxy.ts:8–22  ·  view source on GitHub ↗
(
  req: Request,
  opts?: {
    proxyBasePath?: string
  },
)

Source from the content-addressed store, hash-verified

6import type { WebsocketRequest } from "../wsRouter"
7
8const getProxyTarget = (
9 req: Request,
10 opts?: {
11 proxyBasePath?: string
12 },
13): string => {
14 // If there is a base path, strip it out.
15 const base = (req as any).base || ""
16 // Cast since we only have one port param.
17 const port = parseInt(req.params.port as string, 10)
18 if (isNaN(port)) {
19 throw new HttpError("Invalid port", HttpCode.BadRequest)
20 }
21 return `http://0.0.0.0:${port}${opts?.proxyBasePath || ""}/${req.originalUrl.slice(base.length)}`
22}
23
24export async function proxy(
25 req: Request,

Callers 2

proxyFunction · 0.85
wsProxyFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected