@@ -529,22 +529,40 @@ def _setup_state(self) -> None:
529529
530530 # Set up the Socket.IO AsyncServer.
531531 if not self .sio :
532+ if (
533+ config .transport == "polling"
534+ and (tier := prerequisites .get_user_tier ()) != "enterprise"
535+ ):
536+ console .error (
537+ "The 'polling' transport is only available for Enterprise users. "
538+ + (
539+ "Please upgrade your plan to use this feature."
540+ if tier != "anonymous"
541+ else "Please log in with `reflex login` to use this feature."
542+ )
543+ )
544+ raise SystemExit (1 )
532545 self .sio = AsyncServer (
533546 async_mode = "asgi" ,
534547 cors_allowed_origins = (
535- "*"
536- if config .cors_allowed_origins == ("*" ,)
537- else list (config .cors_allowed_origins )
548+ (
549+ "*"
550+ if config .cors_allowed_origins == ("*" ,)
551+ else list (config .cors_allowed_origins )
552+ )
553+ if config .transport == "websocket"
554+ else []
538555 ),
539- cors_credentials = True ,
556+ cors_credentials = config . transport == "websocket" ,
540557 max_http_buffer_size = environment .REFLEX_SOCKET_MAX_HTTP_BUFFER_SIZE .get (),
541558 ping_interval = environment .REFLEX_SOCKET_INTERVAL .get (),
542559 ping_timeout = environment .REFLEX_SOCKET_TIMEOUT .get (),
543560 json = SimpleNamespace (
544561 dumps = staticmethod (format .json_dumps ),
545562 loads = staticmethod (json .loads ),
546563 ),
547- transports = ["websocket" ],
564+ allow_upgrades = False ,
565+ transports = [config .transport ],
548566 )
549567 elif getattr (self .sio , "async_mode" , "" ) != "asgi" :
550568 msg = f"Custom `sio` must use `async_mode='asgi'`, not '{ self .sio .async_mode } '."
0 commit comments