Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion reflex/reflex.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,13 @@ def _run(
auto_increment=auto_increment_backend,
)

# Apply the new ports to the config.
# Apply the new ports and host to the config.
if frontend_port != config.frontend_port:
config._set_persistent(frontend_port=frontend_port)
if backend_port != config.backend_port:
config._set_persistent(backend_port=backend_port)
if backend_host != config.backend_host:
config._set_persistent(backend_host=backend_host)

# Reload the config to make sure the env vars are persistent.
get_config(reload=True)
Expand Down
16 changes: 11 additions & 5 deletions reflex/utils/exec.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,16 @@ def notify_frontend(url: str, backend_present: bool):
)


def notify_backend():
"""Output a string notifying where the backend is running."""
def notify_backend(host: str | None = None):
"""Output a string notifying where the backend is running.

Args:
host: The backend host. If not provided, falls back to the config value.
"""
config = get_config()
effective_host = host if host is not None else config.backend_host
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://{effective_host}:{config.backend_port}[/bold green]"
)


Expand Down Expand Up @@ -378,7 +384,7 @@ def run_backend(
(web_dir / constants.NOCOMPILE_FILE).touch()

if not frontend_present:
notify_backend()
notify_backend(host)

# Run the backend in development mode.
if should_use_granian():
Expand Down Expand Up @@ -579,7 +585,7 @@ def run_backend_prod(
mount_frontend_compiled_app: Whether to mount the compiled frontend app with the backend.
"""
if not frontend_present:
notify_backend()
notify_backend(host)

environment.REFLEX_MOUNT_FRONTEND_COMPILED_APP.set(mount_frontend_compiled_app)

Expand Down
Loading