Skip to content

Commit

Permalink
Merge pull request #999 from adamantike/misc/enable-gzip-compression
Browse files Browse the repository at this point in the history
misc: Enable GZip compression for backend responses
  • Loading branch information
gantoine committed Jul 14, 2024
2 parents 3dc4863 + d94f542 commit d8ffc1a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions backend/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
)
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from fastapi.middleware.gzip import GZipMiddleware
from handler.auth.base_handler import ALGORITHM
from handler.auth.hybrid_auth import HybridAuthBackend
from handler.auth.middleware import CustomCSRFMiddleware, SessionMiddleware
Expand Down Expand Up @@ -61,6 +62,9 @@ async def lifespan(app: FastAPI) -> AsyncGenerator[None, None]:
exempt_urls=[re.compile(r"^/token.*"), re.compile(r"^/ws")],
)

# Enable GZip compression for responses
app.add_middleware(GZipMiddleware, minimum_size=1024)

# Handles both basic and oauth authentication
app.add_middleware(
AuthenticationMiddleware,
Expand Down

0 comments on commit d8ffc1a

Please sign in to comment.