fix: preserve WEB_HOST scheme in get_default_web_url - #7
Open
xiehuanyi wants to merge 1 commit into
Open
Conversation
Bare hosts still get https://. An explicit http:// or https:// value is kept so self-hosted / Podman setups can point internal MCP callbacks at plain HTTP without a TLS handshake against a non-TLS port. Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates get_default_web_url() in openhands/app_server/config.py to preserve an explicitly provided URL scheme in WEB_HOST, while keeping the historical https:// default for bare hosts—supporting self-hosted HTTP deployments without breaking cloud defaults.
Changes:
- Normalize
WEB_HOSTby stripping whitespace and returningNonewhen unset/blank. - Preserve explicitly schemed
WEB_HOSTvalues (e.g.http://...) instead of always forcinghttps://. - Add unit tests covering unset/empty/whitespace, bare hosts, and explicit
http:///https://handling.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
openhands/app_server/config.py |
Preserves an explicit scheme in WEB_HOST and keeps https:// default for bare hosts. |
tests/unit/app_server/test_get_default_web_url.py |
Adds unit tests for scheme-preservation and empty/unset handling of WEB_HOST. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+102
to
104
| if '://' in web_host: | ||
| return web_host.rstrip('/') | ||
| return f'https://{web_host}' |
Comment on lines
+23
to
+26
| def test_bare_host_with_port(self, monkeypatch): | ||
| monkeypatch.setenv('WEB_HOST', 'host.docker.internal:3000') | ||
| assert get_default_web_url() == 'https://host.docker.internal:3000' | ||
|
|
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.
Summary
get_default_web_url()always prefixedhttps://. That made self-hosted / rootless Podman setups unable to point internal MCP/webhook callbacks at a plain HTTP app server:WEB_HOST=host.docker.internal:3000->https://host.docker.internal:3000(TLS against HTTP)WEB_HOST=http://host.docker.internal:3000->https://http://host.docker.internal:3000Bare hosts still get
https://so cloud is unchanged. If the value already has a scheme, it is passed through.Related: OpenHands/software-agent-sdk#4493 (maintainer asked for this scheme fix). The default 405 with no
WEB_HOSTis a separate host/port issue (OH_SANDBOX_HOST_PORT/ fallbackhttp://host.docker.internal:{host_port}). Conversation hard-fail on MCP connect is OpenHands/software-agent-sdk#4462.Test plan
http:/// explicithttps://tests/unit/app_server/test_get_default_web_url.pyMade with Cursor