File tree Expand file tree Collapse file tree 4 files changed +10
-9
lines changed
Expand file tree Collapse file tree 4 files changed +10
-9
lines changed Original file line number Diff line number Diff line change @@ -854,7 +854,7 @@ export const useEventLoop = (
854854 await connect (
855855 socket ,
856856 dispatch ,
857- [ "websocket" ] ,
857+ [ env . TRANSPORT ] ,
858858 setConnectErrors ,
859859 client_storage ,
860860 navigate ,
Original file line number Diff line number Diff line change @@ -531,20 +531,17 @@ def _setup_state(self) -> None:
531531 if not self .sio :
532532 self .sio = AsyncServer (
533533 async_mode = "asgi" ,
534- cors_allowed_origins = (
535- "*"
536- if config .cors_allowed_origins == ("*" ,)
537- else list (config .cors_allowed_origins )
538- ),
539- cors_credentials = True ,
534+ cors_allowed_origins = [],
535+ cors_credentials = False ,
540536 max_http_buffer_size = environment .REFLEX_SOCKET_MAX_HTTP_BUFFER_SIZE .get (),
541537 ping_interval = environment .REFLEX_SOCKET_INTERVAL .get (),
542538 ping_timeout = environment .REFLEX_SOCKET_TIMEOUT .get (),
543539 json = SimpleNamespace (
544540 dumps = staticmethod (format .json_dumps ),
545541 loads = staticmethod (json .loads ),
546542 ),
547- transports = ["websocket" ],
543+ allow_upgrades = False ,
544+ transports = [config .transport ],
548545 )
549546 elif getattr (self .sio , "async_mode" , "" ) != "asgi" :
550547 msg = f"Custom `sio` must use `async_mode='asgi'`, not '{ self .sio .async_mode } '."
Original file line number Diff line number Diff line change 1010from importlib .util import find_spec
1111from pathlib import Path
1212from types import ModuleType
13- from typing import TYPE_CHECKING , Any , ClassVar
13+ from typing import TYPE_CHECKING , Any , ClassVar , Literal
1414
1515from reflex import constants
1616from reflex .constants .base import LogLevel
@@ -254,6 +254,9 @@ class BaseConfig:
254254 # List of fully qualified import paths of plugins to disable in the app (e.g. reflex.plugins.sitemap.SitemapPlugin).
255255 disable_plugins : list [str ] = dataclasses .field (default_factory = list )
256256
257+ # The transport method for client-server communication.
258+ transport : Literal ["websocket" , "polling" ] = "websocket"
259+
257260 # Whether to skip plugin checks.
258261 _skip_plugins_checks : bool = dataclasses .field (default = False , repr = False )
259262
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ def set_env_json():
2020 str (prerequisites .get_web_dir () / constants .Dirs .ENV_JSON ),
2121 {
2222 ** {endpoint .name : endpoint .get_url () for endpoint in constants .Endpoint },
23+ "TRANSPORT" : get_config ().transport ,
2324 "TEST_MODE" : is_in_app_harness (),
2425 },
2526 )
You can’t perform that action at this time.
0 commit comments