20 lines
487 B
Python
20 lines
487 B
Python
from fastapi.applications import AppType
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
from fastapi.middleware.gzip import GZipMiddleware
|
|
|
|
from .app_settings import settings
|
|
|
|
|
|
def register_middlewares(app: AppType):
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=settings.ORIGINS,
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
app.add_middleware(
|
|
GZipMiddleware,
|
|
minimum_size=1_000,
|
|
)
|