Skip to content

CanvasAnvil is an open source AI diagram maker and flowchart generator - an infinite-canvas diagram editor and self-hosted drawio alternative that writes editable .drawio files. Text to diagram, then fix nodes, layout and labels in place. Also AI presentations, interior design CAD/BOM, posters and infographics.

665 B
Raw Blame
import { ProxyAgent, setGlobalDispatcher } from "undici";

/**
 * Routes Node's built-in `fetch` through the machine's HTTP(S) proxy, when one
 * is configured.
 *
 * Node's `fetch` (undici under the hood) ignores `HTTP_PROXY`/`HTTPS_PROXY`
 * unlike most CLI tools, so on a network where those upstream hosts are only
 * reachable through a proxy, every outbound call this server makes -- image
 * generation included -- needs this wired in before anything else runs.
 */

const proxyUrl =
  process.env.HTTPS_PROXY || process.env.https_proxy || process.env.HTTP_PROXY || process.env.http_proxy;

if (proxyUrl) {
  setGlobalDispatcher(new ProxyAgent(proxyUrl));
}