Fix: Force dashboard command to use localhost URL

Always use localhost for dashboard URL regardless of gateway bind mode
to satisfy browser secure context requirements (HTTPS or localhost).

Changes:
- Force bind="loopback" in resolveControlUiLinks call
- Remove unused bind variable
- Add comment explaining the reasoning

When bind=lan, browsers reject WebSocket connections to LAN IPs due to
secure context policy. Since dashboard is always accessed locally and
gateway bound to 0.0.0.0 accepts both localhost and LAN connections,
using localhost eliminates the error without affecting functionality.

Fixes #16423

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
BinHPdev 2026-02-15 03:04:14 +08:00 committed by Gustavo Madeira Santana
parent 9c5404d95e
commit 5c8cbf8e68
1 changed files with 3 additions and 2 deletions

View File

@ -20,14 +20,15 @@ export async function dashboardCommand(
const snapshot = await readConfigFileSnapshot();
const cfg = snapshot.valid ? snapshot.config : {};
const port = resolveGatewayPort(cfg);
const bind = cfg.gateway?.bind ?? "loopback";
const basePath = cfg.gateway?.controlUi?.basePath;
const customBindHost = cfg.gateway?.customBindHost;
const token = cfg.gateway?.auth?.token ?? process.env.OPENCLAW_GATEWAY_TOKEN ?? "";
// Dashboard always uses localhost regardless of bind mode to avoid
// secure context errors in browsers (which require HTTPS or localhost)
const links = resolveControlUiLinks({
port,
bind,
bind: "loopback",
customBindHost,
basePath,
});