Skip to content

fix: always send GATEWAY_ORIGIN_HEADER on gateway WebSocket connections#287

Open
radicalgeek wants to merge 2 commits intoabhi1693:masterfrom
radicalgeek:pr/fix-gateway-ws-and-api-url
Open

fix: always send GATEWAY_ORIGIN_HEADER on gateway WebSocket connections#287
radicalgeek wants to merge 2 commits intoabhi1693:masterfrom
radicalgeek:pr/fix-gateway-ws-and-api-url

Conversation

@radicalgeek
Copy link

Without an explicit Origin header, Python websockets defaults to using the target URL as the origin (e.g. http://dev-team-gateway.dev-team.svc.cluster.local:18789) which the OpenClaw gateway rejects unless explicitly allowlisted.

Port the GATEWAY_ORIGIN_HEADER approach from the main branch: always send Origin: https://mission-control.radicalgeek.co.uk which is already in the gateway's controlUi.allowedOrigins list.

Fixes: 'origin not allowed' error in Mission Control UI

Task / context

  • Mission Control task:
  • Why:

Scope

  • <bullet 1>
  • <bullet 2>

Out of scope

Evidence / validation

  • make check (or explain what you ran instead)
  • E2E (if applicable): <cypress run / screenshots>
  • Logs/links:

Screenshots (UI changes)

Desktop Mobile

Docs impact

  • No user/operator docs changes required
  • Docs updated: <paths/links>

Risk / rollout notes

  • Risk level: low / medium / high
  • Rollback plan (if needed):

Checklist

  • Branch created from origin/master (no unrelated commits)
  • PR is focused (one theme)
  • No secrets in code/logs/docs
  • If API/behavior changes: docs updated (OpenAPI + docs/reference/api.md)

Without an explicit Origin header, Python websockets defaults to using
the target URL as the origin (e.g. http://dev-team-gateway.dev-team.svc.cluster.local:18789)
which the OpenClaw gateway rejects unless explicitly allowlisted.

Port the GATEWAY_ORIGIN_HEADER approach from the main branch: always
send Origin: https://mission-control.radicalgeek.co.uk which is
already in the gateway's controlUi.allowedOrigins list.

Fixes: 'origin not allowed' error in Mission Control UI
Copilot AI review requested due to automatic review settings March 16, 2026 08:46
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adjusts the OpenClaw gateway WebSocket RPC client to always send a fixed Origin header during the WebSocket upgrade so the gateway accepts connections based on its controlUi.allowedOrigins configuration.

Changes:

  • Introduces a GATEWAY_ORIGIN_HEADER constant for the Origin value.
  • Updates gateway WebSocket connection helpers to always include the Origin header via additional_headers.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines +408 to 412
# Always send the MC origin header so the gateway accepts the connection
# regardless of the gateway URL (avoids "origin not allowed" rejections).
ssl_context = _create_ssl_context(config)
connect_kwargs: dict[str, Any] = {"ping_interval": None}
if origin is not None:
connect_kwargs["origin"] = origin
connect_kwargs: dict[str, Any] = {"ping_interval": None, "additional_headers": {"Origin": GATEWAY_ORIGIN_HEADER}}
if ssl_context is not None:
- Make gateway Origin header configurable (gateway_origin/base_url)
- Remove unused _build_control_ui_origin helper + test
- Add tests asserting Origin header is sent in gateway WS calls
radicalgeek pushed a commit to radicalgeek/openclaw-mission-control that referenced this pull request Mar 16, 2026
- Make gateway Origin header configurable (gateway_origin/base_url)
- Remove unused _build_control_ui_origin helper + test
- Add tests asserting Origin header is sent in gateway WS calls
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants