added proxy support

This commit is contained in:
macm1
2026-02-22 19:51:17 +03:00
parent e33bcf030a
commit c3ba720d0b
4 changed files with 46 additions and 1 deletions
@@ -0,0 +1,29 @@
"use strict";
/**
* Enable HTTP(S) proxy support for Node/undici before OpenClaw initializes.
* We load undici from OpenClaw's own node_modules path to avoid relying on
* global module resolution from this shim's location.
*/
(function applyProxyFromEnv() {
const hasProxyEnv =
!!process.env.HTTPS_PROXY ||
!!process.env.HTTP_PROXY ||
!!process.env.https_proxy ||
!!process.env.http_proxy;
if (!hasProxyEnv) {
return;
}
try {
const path = require("node:path");
const globalModulesRoot =
process.env.OPENCLAW_GLOBAL_NODE_MODULES || "/usr/lib/node_modules";
const undiciPath = path.join(globalModulesRoot, "openclaw", "node_modules", "undici");
const { EnvHttpProxyAgent, setGlobalDispatcher } = require(undiciPath);
setGlobalDispatcher(new EnvHttpProxyAgent());
} catch (_err) {
// Keep startup resilient if module layout changes in future releases.
}
})();