From cefbab28b738cb0a2c4939c00d3bea5337ee772b Mon Sep 17 00:00:00 2001 From: stswangzhiping <59632378+stswangzhiping@users.noreply.github.com> Date: Tue, 24 Mar 2026 11:38:58 +0800 Subject: [PATCH] feat: configure openclaw allowedOrigins on activation Made-with: Cursor --- lib/client.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/lib/client.js b/lib/client.js index c30a510..3da76e8 100644 --- a/lib/client.js +++ b/lib/client.js @@ -391,6 +391,25 @@ class ClawClient { led.status.setApps(); led.display.showTime(); log.info('clawd', `已激活 claw_id = ${this._cfg.claw_id}`); + this._configureOpenClaw(this._cfg.claw_id); + } + } + + // ── OpenClaw 配置 ──────────────────────────────────────────────────────────── + + _configureOpenClaw(clawId) { + try { + const origins = JSON.stringify([ + 'http://0.0.0.0:18789', + `https://${clawId}.claw.cutos.ai`, + ]); + execFileSync('openclaw', ['config', 'set', 'gateway.controlUi.allowedOrigins', origins], { + timeout: 5000, + stdio: 'ignore', + }); + log.info('clawd', `openclaw allowedOrigins 已配置: ${clawId}.claw.cutos.ai`); + } catch (e) { + log.warn('clawd', `openclaw 配置失败(可能未安装): ${e.message}`); } }