Skip to content

fix(onboard): CORS origin mismatch when CHAT_UI_URL is behind a reverse proxy #3000

Closed

Description

@senthilr-nv

Bug

When CHAT_UI_URL is set to an HTTPS URL without an explicit port — exactly as documented at Remote Dashboard Access — onboard unconditionally overrides the port with the internal dashboard port (18789).

Root cause: src/lib/onboard.ts line ~4002:

parsed.port = String(effectivePort);

This produces:

"allowedOrigins": [
  "http://127.0.0.1:18789",
  "https://brev-host.brevlab.com:18789"
]

But when the dashboard is accessed through a reverse proxy (Brev Cloudflare Tunnel, nginx, Caddy, etc.), the browser sends origin https://brev-host.brevlab.com (port 443) — which doesn't match, causing:

origin not allowed (open the Control UI from the gateway host or allow it in gateway.controlUi.allowedOrigins)

The docs say to do exactly this:

set CHAT_UI_URL to the origin the browser will use before running setup:
export CHAT_UI_URL="https://openclaw0-<id>.brevlab.com"

Repro

  1. CHAT_UI_URL="https://brev-host.brevlab.com" nemoclaw onboard --non-interactive
  2. Access dashboard via Brev tunnel: https://brev-host.brevlab.com/chat?session=main
  3. CORS error: "origin not allowed"

Workaround

Manually add the portless origin via kubectl:

docker exec openshell-cluster-nemoclaw kubectl exec my-assistant -n openshell -- python3 -c "
import json
path = '/sandbox/.openclaw/openclaw.json'
with open(path) as f:
    config = json.load(f)
config['gateway']['controlUi']['allowedOrigins'].append('https://brev-host.brevlab.com')
with open(path, 'w') as f:
    json.dump(config, f, indent=2)
"

Then: nemoclaw my-assistant connect --probe-only

Suggested fix

In scripts/generate-openclaw-config.py (line ~197), when the user-provided CHAT_UI_URL had no explicit port, include both the original origin and the port-annotated origin in allowedOrigins. Safe (same host) and covers both direct and proxied access.

Affected platforms

Any reverse proxy: Brev (Cloudflare Tunnel), nginx, Caddy, Tailscale Funnel, etc.

Activity

  1. added
    platform: brev
    and removed on May 4, 2026
  2. senthilr-nv commented on May 4, 2026

    @senthilr-nv
    CollaboratorAuthor

    Prior art: This is the remaining gap from the #795 / #20 lineage. PR #812 (merged Apr 3) baked CHAT_UI_URL into the Docker build, and PR #2440 (merged Apr 24) injected NEMOCLAW_DASHBOARD_PORT into the sandbox env. Both fixed the plumbing, but the port override at onboard.ts:4002 still produces a port-annotated origin that doesn't match when access comes through a reverse proxy (Brev Cloudflare Tunnel, nginx, etc.).

  3. self-assigned this
    on May 4, 2026
  4. added 5 commits that reference this issue on May 4, 2026
    6583d8e
    10fe201
    6ce3c7d
    70954ac
    76832c6
  5. added a commit that references this issue on May 4, 2026
    42e0f62
  6. added
    area: cli
    and removed on Jun 3, 2026
  7. added theissue type on Jun 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area: cliplatform: brev

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions