Skip to content

Commit e5eac08

Browse files
committed
Revert "[ENG-4005] Proxy backend requests on '/' to the frontend (#3300)" (#4614)
This reverts commit 438b31f.
1 parent 727c87c commit e5eac08

File tree

12 files changed

+15
-782
lines changed

12 files changed

+15
-782
lines changed

.github/workflows/integration_tests.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,6 @@ jobs:
8484
run: |
8585
poetry run reflex export --backend-only
8686
- name: Check run --backend-only before init for counter example
87-
env:
88-
WAIT_FOR_LISTENING_PORT_ARGS: --path ping
8987
run: |
9088
poetry run bash scripts/integration.sh ./reflex-examples/counter dev 8001 --backend-only --backend-port 8001
9189
- name: Init Website for counter example

.github/workflows/integration_tests_wsl.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ jobs:
7878
shell: wsl-bash {0}
7979
run: |
8080
export TELEMETRY_ENABLED=false
81-
export WAIT_FOR_LISTENING_PORT_ARGS="--path ping"
8281
dos2unix scripts/integration.sh
8382
poetry run bash scripts/integration.sh ./reflex-examples/counter dev 8001 --backend-only --backend-port 8001
8483
- name: Init Website for counter example

poetry.lock

Lines changed: 5 additions & 570 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ setuptools = ">=75.0"
4949
httpx = ">=0.25.1,<1.0"
5050
twine = ">=4.0.0,<7.0"
5151
tomlkit = ">=0.12.4,<1.0"
52-
asgiproxy = { version = "==0.1.1", optional = true }
5352
lazy_loader = ">=0.4"
5453
reflex-chakra = ">=0.6.0"
5554
typing_extensions = ">=4.6.0"
@@ -73,14 +72,10 @@ selenium = ">=4.11.0,<5.0"
7372
pytest-benchmark = ">=4.0.0,<6.0"
7473
playwright = ">=1.46.0"
7574
pytest-playwright = ">=0.5.1"
76-
asgiproxy = "==0.1.1"
7775

7876
[tool.poetry.scripts]
7977
reflex = "reflex.reflex:cli"
8078

81-
[tool.poetry.extras]
82-
proxy = ["asgiproxy"]
83-
8479
[build-system]
8580
requires = ["poetry-core>=1.5.1"]
8681
build-backend = "poetry.core.masonry.api"

reflex/app.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -331,12 +331,6 @@ def __post_init__(self):
331331

332332
self.register_lifespan_task(windows_hot_reload_lifespan_hack)
333333

334-
# Enable proxying to frontend server.
335-
if not environment.REFLEX_BACKEND_ONLY.get():
336-
from reflex.proxy import proxy_middleware
337-
338-
self.register_lifespan_task(proxy_middleware)
339-
340334
def _enable_state(self) -> None:
341335
"""Enable state for the app."""
342336
if not self.state:

reflex/config.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626

2727
from typing_extensions import Annotated, get_type_hints
2828

29-
from reflex.utils.console import set_log_level
3029
from reflex.utils.exceptions import ConfigError, EnvironmentVarValueError
3130
from reflex.utils.types import GenericType, is_union, value_inside_optional
3231

@@ -600,7 +599,6 @@ class Config(Base):
600599
class Config:
601600
"""Pydantic config for the config."""
602601

603-
use_enum_values = False
604602
validate_assignment = True
605603

606604
# The name of the app (should match the name of the app directory).
@@ -720,9 +718,6 @@ def __init__(self, *args, **kwargs):
720718
self._non_default_attributes.update(kwargs)
721719
self._replace_defaults(**kwargs)
722720

723-
# Set the log level for this process
724-
set_log_level(self.loglevel)
725-
726721
if (
727722
self.state_manager_mode == constants.StateManagerMode.REDIS
728723
and not self.redis_url

reflex/proxy.py

Lines changed: 0 additions & 119 deletions
This file was deleted.

reflex/testing.py

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
import reflex.utils.prerequisites
4545
import reflex.utils.processes
4646
from reflex.config import environment
47-
from reflex.proxy import proxy_middleware
4847
from reflex.state import (
4948
BaseState,
5049
StateManager,
@@ -299,9 +298,6 @@ def _initialize_app(self):
299298
self.state_manager = StateManagerRedis.create(self.app_instance.state)
300299
else:
301300
self.state_manager = self.app_instance._state_manager
302-
# Disable proxy for app harness tests.
303-
if proxy_middleware in self.app_instance.lifespan_tasks:
304-
self.app_instance.lifespan_tasks.remove(proxy_middleware)
305301

306302
def _reload_state_module(self):
307303
"""Reload the rx.State module to avoid conflict when reloading."""
@@ -369,12 +365,9 @@ async def _reset_backend_state_manager(self):
369365
def _start_frontend(self):
370366
# Set up the frontend.
371367
with chdir(self.app_path):
372-
backend_host, backend_port = self._poll_for_servers().getsockname()
373368
config = reflex.config.get_config()
374-
config.backend_port = backend_port
375369
config.api_url = "http://{0}:{1}".format(
376-
backend_host,
377-
backend_port,
370+
*self._poll_for_servers().getsockname(),
378371
)
379372
reflex.utils.build.setup_frontend(self.app_path)
380373

@@ -399,7 +392,6 @@ def _wait_frontend(self):
399392
self.frontend_url = m.group(1)
400393
config = reflex.config.get_config()
401394
config.deploy_url = self.frontend_url
402-
config.frontend_port = int(self.frontend_url.rpartition(":")[2])
403395
break
404396
if self.frontend_url is None:
405397
raise RuntimeError("Frontend did not start")
@@ -923,20 +915,17 @@ def _run_frontend(self):
923915
root=web_root,
924916
error_page_map=error_page_map,
925917
) as self.frontend_server:
926-
config = reflex.config.get_config()
927-
config.frontend_port = self.frontend_server.server_address[1]
928-
self.frontend_url = f"http://localhost:{config.frontend_port}"
918+
self.frontend_url = "http://localhost:{1}".format(
919+
*self.frontend_server.socket.getsockname()
920+
)
929921
self.frontend_server.serve_forever()
930922

931923
def _start_frontend(self):
932924
# Set up the frontend.
933925
with chdir(self.app_path):
934-
backend_host, backend_port = self._poll_for_servers().getsockname()
935926
config = reflex.config.get_config()
936-
config.backend_port = backend_port
937927
config.api_url = "http://{0}:{1}".format(
938-
backend_host,
939-
backend_port,
928+
*self._poll_for_servers().getsockname(),
940929
)
941930
reflex.reflex.export(
942931
zipping=False,

reflex/utils/console.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
from __future__ import annotations
44

5-
import os
6-
75
from rich.console import Console
86
from rich.progress import MofNCompleteColumn, Progress, TimeElapsedColumn
97
from rich.prompt import Prompt
@@ -14,7 +12,7 @@
1412
_console = Console()
1513

1614
# The current log level.
17-
_LOG_LEVEL = LogLevel.DEFAULT
15+
_LOG_LEVEL = LogLevel.INFO
1816

1917
# Deprecated features who's warning has been printed.
2018
_EMITTED_DEPRECATION_WARNINGS = set()
@@ -63,9 +61,6 @@ def set_log_level(log_level: LogLevel):
6361
raise ValueError(f"Invalid log level: {log_level}") from ae
6462

6563
global _LOG_LEVEL
66-
if log_level != _LOG_LEVEL:
67-
# Set the loglevel persistently for subprocesses
68-
os.environ["LOGLEVEL"] = log_level.value
6964
_LOG_LEVEL = log_level
7065

7166

scripts/integration.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@ if [ -f /proc/$pid/winpid ]; then
3434
echo "Windows detected, passing winpid $pid to port waiter"
3535
fi
3636

37-
python scripts/wait_for_listening_port.py $check_ports --timeout=900 --server-pid "$pid" $WAIT_FOR_LISTENING_PORT_ARGS
37+
python scripts/wait_for_listening_port.py $check_ports --timeout=900 --server-pid "$pid"

0 commit comments

Comments
 (0)