Skip to content

Commit 10a5feb

Browse files
committed
fix CORS
1 parent 38ff389 commit 10a5feb

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

reflex/app.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -531,8 +531,16 @@ def _setup_state(self) -> None:
531531
if not self.sio:
532532
self.sio = AsyncServer(
533533
async_mode="asgi",
534-
cors_allowed_origins=[],
535-
cors_credentials=False,
534+
cors_allowed_origins=(
535+
(
536+
"*"
537+
if config.cors_allowed_origins == ("*",)
538+
else list(config.cors_allowed_origins)
539+
)
540+
if config.transport == "websocket"
541+
else []
542+
),
543+
cors_credentials=config.transport == "websocket",
536544
max_http_buffer_size=environment.REFLEX_SOCKET_MAX_HTTP_BUFFER_SIZE.get(),
537545
ping_interval=environment.REFLEX_SOCKET_INTERVAL.get(),
538546
ping_timeout=environment.REFLEX_SOCKET_TIMEOUT.get(),

0 commit comments

Comments
 (0)