Skip to content

chore(config): fix logic to separate config for WEB_URL and WEB_PORT#147

Closed
dchien234 wants to merge 2 commits into
hummingbot:mainfrom
dchien234:chore/refactor-web-url
Closed

chore(config): fix logic to separate config for WEB_URL and WEB_PORT#147
dchien234 wants to merge 2 commits into
hummingbot:mainfrom
dchien234:chore/refactor-web-url

Conversation

@dchien234

@dchien234 dchien234 commented Jul 6, 2026

Copy link
Copy Markdown

Problem

WEB_URL currently does double duty as both the public URL used in links sent to users and the port source used to bind the web server. That works for a local value such as http://localhost:8088, but it breaks common reverse-proxy and Kubernetes deployments where the public URL is HTTPS while the application should still bind to an internal port such as 8088.

Reproduction

Configure Condor behind an ingress or reverse proxy with a public URL and an internal bind port:

WEB_URL=https://condor.example.com
WEB_PORT=8088

Before this change, utils.config ignored WEB_PORT whenever WEB_URL was set and derived the bind port from the URL scheme instead:

WEB_URL = "https://condor.example.com"
WEB_PORT = 443

That means links point to the right public host, but the local web server tries to bind to 443 instead of the intended internal port.

Fix

Separate the two configuration concerns in utils/config.py:

  • WEB_URL remains the public URL used in Telegram/web links.
  • WEB_PORT is the local port used to bind the web server.
  • If WEB_PORT is set, it always wins for binding.
  • If WEB_PORT is not set, the existing fallback behavior remains: use the explicit port from WEB_URL, infer 443 for HTTPS, infer 80 for HTTP, or default to http://localhost:8088.

Scope

  • One file changed: utils/config.py.
  • No new dependencies.
  • Keeps existing local behavior for WEB_URL=http://localhost:8088.
  • Keeps backward compatibility for deployments that only set WEB_URL or only set WEB_PORT.
  • Adds explicit support for reverse-proxy/Kubernetes-style configuration where public URL and bind port differ.

Validated

Targeted validation passed for the expected config matrix:

  • WEB_URL=https://condor.example.com, WEB_PORT=8088 -> public URL stays HTTPS, bind port is 8088.
  • WEB_URL=http://localhost:8088 -> bind port remains 8088.
  • WEB_URL=https://condor.example.com without WEB_PORT -> bind port falls back to 443.
  • WEB_PORT=9090 without WEB_URL -> public URL becomes http://localhost:9090.
  • No web env vars -> default remains http://localhost:8088 / 8088.

Also validated:

  • py_compile passed for utils/config.py.
  • git diff --check passed.

Full-suite note: uv run pytest was attempted, but collection stops before test execution because tests/trading_agent/test_risk_drawdown.py imports condor.trading_agent, which is not present in this checkout. That failure is outside this one-file config change.

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.

2 participants