fix: dynamically report backend_host in terminal logs #6165#6177
fix: dynamically report backend_host in terminal logs #6165#6177pranavmanglik wants to merge 4 commits intoreflex-dev:mainfrom
Conversation
Greptile SummaryThis PR fixes a bug in Changes made:
Issue found:
Confidence Score: 3/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["reflex run [--backend-host HOST]"] --> B["_run() in reflex.py"]
B --> C["backend_host = cli_arg OR config.backend_host"]
C --> D{"frontend present?"}
D -- No --> E["run_backend(host, port, ...)"]
D -- Yes --> F["run_frontend + run_backend (concurrent)"]
E --> G{"not frontend_present?"}
G -- Yes --> H["notify_backend()"]
H --> I["config = get_config()"]
I --> J["reads config.backend_host ← may differ from resolved 'host'"]
J --> K["Logs: Backend running at http://config.backend_host:port"]
E --> L["Binds server to resolved 'host'"]
K -.->|"Mismatch when --backend-host CLI arg used"| L
|
reflex/utils/exec.py
Outdated
| """Output a string notifying where the backend is running.""" | ||
| console.print( | ||
| f"Backend running at: [bold green]http://0.0.0.0:{get_config().backend_port}[/bold green]" | ||
| f"Backend running at: [bold green]http://{get_config().backend_host}:{get_config().backend_port}[/bold green]" |
There was a problem hiding this comment.
instead of calling get_config() twice, cache the returned config and reference it in both places.
There was a problem hiding this comment.
Thanks for your response, i actually new to open source. I thought about it but then had doubt if it was that necessary as it was being called twice only.
All Submissions:
Type of change
New Feature Submission:
Changes To Core Features:
Pull Request Details
Descriptive Title
fix: accurately report configured backend_host in terminal logsDescription of Changes
Currently, the
notify_backendfunction inreflex/utils/exec.pyhas the backend IP hardcoded as0.0.0.0. This leads to misleading terminal output when a user has explicitly configured a custombackend_host(e.g.,127.0.0.1for local-only development) in theirrxconfig.py.This PR modifies the notification logic to dynamically pull the
backend_hostfrom the Reflex configuration, ensuring the logs match the actual network binding. This improves developer clarity and assists in verifying security configurations.Testing performed:
backend_host="127.0.0.1"inrxconfig.py.http://127.0.0.1:8000instead of the hardcoded0.0.0.0.ruff) passes.Closing Issues
Closes #6165