From 639d26252e528c9c37a5f553b11eb94376d8792d Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Thu, 6 Nov 2025 15:21:41 -0500 Subject: [PATCH] fix: Socket.IO CORS warning Co-Authored-By: Gero Doll <6284675+limbicnation@users.noreply.github.com> --- backend/open_webui/socket/main.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/backend/open_webui/socket/main.py b/backend/open_webui/socket/main.py index 781f2cb1ae..818a57807f 100644 --- a/backend/open_webui/socket/main.py +++ b/backend/open_webui/socket/main.py @@ -53,6 +53,9 @@ log.setLevel(SRC_LOG_LEVELS["SOCKET"]) REDIS = None +# Configure CORS for Socket.IO +SOCKETIO_CORS_ORIGINS = "*" if CORS_ALLOW_ORIGIN == ["*"] else CORS_ALLOW_ORIGIN + if WEBSOCKET_MANAGER == "redis": if WEBSOCKET_SENTINEL_HOSTS: mgr = socketio.AsyncRedisManager( @@ -63,7 +66,7 @@ if WEBSOCKET_MANAGER == "redis": else: mgr = socketio.AsyncRedisManager(WEBSOCKET_REDIS_URL) sio = socketio.AsyncServer( - cors_allowed_origins=CORS_ALLOW_ORIGIN, + cors_allowed_origins=SOCKETIO_CORS_ORIGINS, async_mode="asgi", transports=(["websocket"] if ENABLE_WEBSOCKET_SUPPORT else ["polling"]), allow_upgrades=ENABLE_WEBSOCKET_SUPPORT, @@ -72,7 +75,7 @@ if WEBSOCKET_MANAGER == "redis": ) else: sio = socketio.AsyncServer( - cors_allowed_origins=CORS_ALLOW_ORIGIN, + cors_allowed_origins=SOCKETIO_CORS_ORIGINS, async_mode="asgi", transports=(["websocket"] if ENABLE_WEBSOCKET_SUPPORT else ["polling"]), allow_upgrades=ENABLE_WEBSOCKET_SUPPORT,