src/node/routes/pathProxy.ts/proxy
export async function proxy(
  req: Request,
  res: Response,
  opts?: {
    passthroughPath?: boolean
  },
): Promise<void> {
  if (!(await authenticated(req))) {
    // If visiting the root (/:port only) redirect to the login page.
    if (!req.params[0] || req.params[0] === "/") {
      const to = self(req)
      return redirect(req, res, "login", {
        to: to !== "/" ? to : undefined,
      })
    }
    throw new HttpError("Unauthorized", HttpCode.Unauthorized)
  }

  if (!opts?.passthroughPath) {
    // Absolute redirects need to be based on the subpath when rewriting.
    // See proxy.ts.
    ;(req as any).base = req.path.split(path.sep).slice(0, 3).join(path.sep)
  }

  _proxy.web(req, res, {
    ignorePath: true,
    target: getProxyTarget(req, opts?.passthroughPath),
  })
}