Merge pull request #999 from adamantike/misc/enable-gzip-compression

misc: Enable GZip compression for backend responses
This commit is contained in:
Georges-Antoine Assi
2024-07-14 11:12:55 -04:00
committed by GitHub

View File

@@ -28,6 +28,7 @@ from endpoints import (
)
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
@@ -61,6 +62,9 @@ if "pytest" not in sys.modules and not DISABLE_CSRF_PROTECTION:
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,