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

Function maybeProxy

src/node/routes/domainProxy.ts:37–54  ·  view source on GitHub ↗
(req: Request)

Source from the content-addressed store, hash-verified

35 *
36 */
37const maybeProxy = (req: Request): string | undefined => {
38 const reqDomain = getHost(req)
39 if (reqDomain === undefined) {
40 return undefined
41 }
42
43 const regexs = proxyDomainsToRegex(req.args["proxy-domain"])
44
45 for (const regex of regexs) {
46 const match = reqDomain.match(regex)
47
48 if (match) {
49 return match[1] // match[1] contains the port
50 }
51 }
52
53 return undefined
54}
55
56router.all(/.*/, async (req, res, next) => {
57 const port = maybeProxy(req)

Callers 1

domainProxy.tsFile · 0.85

Calls 2

getHostFunction · 0.90
proxyDomainsToRegexFunction · 0.85

Tested by

no test coverage detected