added proxy support
This commit is contained in:
@@ -7,6 +7,7 @@ All notable changes to the OpenClaw Assistant Home Assistant Add-on will be docu
|
||||
### Changed
|
||||
- Bump OpenClaw to 2026.2.21-2.
|
||||
- Add Home Assistant `share` and `media` mounts to the add-on (`map: share:rw, media:rw`).
|
||||
- Keep official OpenClaw npm release and add startup proxy shim for `HTTP_PROXY/HTTPS_PROXY` support in undici fetch.
|
||||
|
||||
## [0.5.47] - 2026-02-21
|
||||
|
||||
|
||||
@@ -100,7 +100,7 @@ RUN if [ -x /home/linuxbrew/.linuxbrew/bin/brew ]; then \
|
||||
fi
|
||||
USER root
|
||||
|
||||
# Install OpenClaw globally
|
||||
# Install OpenClaw globally (official npm release)
|
||||
RUN npm config set fund false && npm config set audit false \
|
||||
&& npm install -g openclaw@2026.2.21-2
|
||||
|
||||
@@ -124,6 +124,7 @@ fi
|
||||
EOF
|
||||
COPY run.sh /run.sh
|
||||
COPY oc_config_helper.py /oc_config_helper.py
|
||||
COPY openclaw-proxy-shim.cjs /usr/local/lib/openclaw-proxy-shim.cjs
|
||||
COPY nginx.conf.tpl /etc/nginx/nginx.conf.tpl
|
||||
COPY landing.html.tpl /etc/nginx/landing.html.tpl
|
||||
RUN chmod +x /run.sh /oc_config_helper.py \
|
||||
|
||||
@@ -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.
|
||||
}
|
||||
})();
|
||||
@@ -347,6 +347,20 @@ else
|
||||
echo "INFO: Run 'openclaw onboard' first, then restart the add-on"
|
||||
fi
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Proxy shim for undici/OpenClaw startup
|
||||
# Keep official OpenClaw npm release while enabling HTTP(S)_PROXY support.
|
||||
# ------------------------------------------------------------------------------
|
||||
OPENCLAW_GLOBAL_NODE_MODULES="$(HOME=/root npm root -g 2>/dev/null || true)"
|
||||
if [ -f /usr/local/lib/openclaw-proxy-shim.cjs ]; then
|
||||
if [ -n "${NODE_OPTIONS:-}" ]; then
|
||||
export NODE_OPTIONS="--require /usr/local/lib/openclaw-proxy-shim.cjs ${NODE_OPTIONS}"
|
||||
else
|
||||
export NODE_OPTIONS="--require /usr/local/lib/openclaw-proxy-shim.cjs"
|
||||
fi
|
||||
export OPENCLAW_GLOBAL_NODE_MODULES
|
||||
fi
|
||||
|
||||
echo "Starting OpenClaw Assistant gateway (openclaw)..."
|
||||
openclaw gateway run &
|
||||
GW_PID=$!
|
||||
|
||||
Reference in New Issue
Block a user