diff --git a/reflex/config.py b/reflex/config.py index 891911ca6..c51e0a25a 100644 --- a/reflex/config.py +++ b/reflex/config.py @@ -544,6 +544,12 @@ class EnvironmentVariables: # Whether to run the frontend only. Exclusive with REFLEX_BACKEND_ONLY. REFLEX_FRONTEND_ONLY: EnvVar[bool] = env_var(False) + # The port to run the frontend on. + REFLEX_FRONTEND_PORT: EnvVar[int] = env_var(None) + + # The port to run the backend on. + REFLEX_BACKEND_PORT: EnvVar[int] = env_var(None) + # Reflex internal env to reload the config. RELOAD_CONFIG: EnvVar[bool] = env_var(False, internal=True) diff --git a/reflex/reflex.py b/reflex/reflex.py index 340fdfd71..930261798 100644 --- a/reflex/reflex.py +++ b/reflex/reflex.py @@ -289,10 +289,14 @@ def run( envvar=environment.REFLEX_BACKEND_ONLY.name, ), frontend_port: int = typer.Option( - config.frontend_port, help="Specify a different frontend port." + config.frontend_port, + help="Specify a different frontend port.", + envvar=environment.REFLEX_FRONTEND_PORT.name, ), backend_port: int = typer.Option( - config.backend_port, help="Specify a different backend port." + config.backend_port, + help="Specify a different backend port.", + envvar=environment.REFLEX_BACKEND_PORT.name, ), backend_host: str = typer.Option( config.backend_host, help="Specify the backend host."