From 4da75a9e78e973199330018be3d17f4027fc5bce Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Mon, 26 May 2025 14:18:29 +0400 Subject: [PATCH] feat: GZip, Brotli, ZStd compression middleware support Co-Authored-By: Jason Baker --- backend/open_webui/main.py | 3 +++ backend/requirements.txt | 2 ++ pyproject.toml | 2 ++ 3 files changed, 7 insertions(+) diff --git a/backend/open_webui/main.py b/backend/open_webui/main.py index 0a274d028..999993e84 100644 --- a/backend/open_webui/main.py +++ b/backend/open_webui/main.py @@ -40,6 +40,8 @@ from fastapi.middleware.cors import CORSMiddleware from fastapi.responses import JSONResponse, RedirectResponse from fastapi.staticfiles import StaticFiles +from starlette_compress import CompressMiddleware + from starlette.exceptions import HTTPException as StarletteHTTPException from starlette.middleware.base import BaseHTTPMiddleware from starlette.middleware.sessions import SessionMiddleware @@ -963,6 +965,7 @@ class RedirectMiddleware(BaseHTTPMiddleware): # Add the middleware to the app +app.add_middleware(CompressMiddleware) app.add_middleware(RedirectMiddleware) app.add_middleware(SecurityHeadersMiddleware) diff --git a/backend/requirements.txt b/backend/requirements.txt index bcb07258e..9930cd3b6 100644 --- a/backend/requirements.txt +++ b/backend/requirements.txt @@ -12,6 +12,8 @@ aiohttp==3.11.11 async-timeout aiocache aiofiles +starlette-compress==1.6.0 + sqlalchemy==2.0.38 alembic==1.14.0 diff --git a/pyproject.toml b/pyproject.toml index 4fb8d1ed5..51ea65890 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,6 +21,8 @@ dependencies = [ "aiocache", "aiofiles", + "starlette-compress==1.6.0", + "sqlalchemy==2.0.38", "alembic==1.14.0", "peewee==3.18.1",