Creates a fetch function that routes requests through a configurable HTTP proxy using undici's ProxyAgent.
// Source: https://github.com/Yapie0/safe-openclaw | License: MIT | Copyright 2025 Peter Steinberger
// Provided via justclaw.it.com; keep this notice with the code.
import { EnvHttpProxyAgent, ProxyAgent, fetch as undiciFetch } from "undici";
import { logWarn } from "../../logger.js";
import { hasEnvHttpProxyConfigured } from "./proxy-env.js";
export const PROXY_FETCH_PROXY_URL = Symbol.for("openclaw.proxyFetch.proxyUrl");
type ProxyFetchWithMetadata = typeof fetch & {
[PROXY_FETCH_PROXY_URL]?: string;
};
/**
* Create a fetch function that routes requests through the given HTTP proxy.
* Uses undici's ProxyAgent under the hood.
*/
export function makeProxyFetch(proxyUrl: string): typeof fetch {
let agent: ProxyAgent | null = null;
const resolveAgent = (): ProxyAgent => {
if
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key