fix: always send GATEWAY_ORIGIN_HEADER on gateway WebSocket connections#287
Open
radicalgeek wants to merge 2 commits intoabhi1693:masterfrom
Open
fix: always send GATEWAY_ORIGIN_HEADER on gateway WebSocket connections#287radicalgeek wants to merge 2 commits intoabhi1693:masterfrom
radicalgeek wants to merge 2 commits intoabhi1693:masterfrom
Conversation
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
Contributor
There was a problem hiding this comment.
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_HEADERconstant 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
abhi1693
approved these changes
Mar 16, 2026
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
Scope
Out of scope
Evidence / validation
make check(or explain what you ran instead)Screenshots (UI changes)
Docs impact
Risk / rollout notes
Checklist
origin/master(no unrelated commits)docs/reference/api.md)