feat: add ENABLE_WEBSOCKET_SUPPORT to force socket.io to ignore websocket upgrades

This commit is contained in:
Jun Siang Cheah
2024-09-09 23:17:17 +01:00
parent 698976add0
commit 827c419251
3 changed files with 8 additions and 11 deletions

View File

@@ -2,16 +2,15 @@ import asyncio
import socketio
from open_webui.apps.webui.models.users import Users
from open_webui.config import ENABLE_WEBSOCKET_SUPPORT
from open_webui.env import ENABLE_WEBSOCKET_SUPPORT
from open_webui.utils.utils import decode_token
sio = socketio.AsyncServer(
cors_allowed_origins=[],
async_mode="asgi",
transports=(
["polling", "websocket"] if ENABLE_WEBSOCKET_SUPPORT.value else ["polling"]
),
allow_upgrades=ENABLE_WEBSOCKET_SUPPORT.value,
transports=(["polling", "websocket"] if ENABLE_WEBSOCKET_SUPPORT else ["polling"]),
allow_upgrades=ENABLE_WEBSOCKET_SUPPORT,
always_connect=True,
)
app = socketio.ASGIApp(sio, socketio_path="/ws/socket.io")