refactor(api): update middleware and cors configuration
This commit is contained in:
parent
17a4251eea
commit
2aafd525cd
1 changed files with 11 additions and 2 deletions
13
api.py
13
api.py
|
|
@ -95,7 +95,11 @@ from utils.generic_functions import (
|
||||||
universign_envoyer,
|
universign_envoyer,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
from middleware.security import SwaggerAuthMiddleware, ApiKeyMiddleware
|
||||||
from core.dependencies import get_current_user
|
from core.dependencies import get_current_user
|
||||||
|
from config.cors_config import setup_cors
|
||||||
|
from routes.api_keys import router as api_keys_router
|
||||||
|
|
||||||
if os.path.exists("/app"):
|
if os.path.exists("/app"):
|
||||||
LOGS_DIR = FilePath("/app/logs")
|
LOGS_DIR = FilePath("/app/logs")
|
||||||
|
|
@ -162,13 +166,18 @@ app = FastAPI(
|
||||||
openapi_tags=TAGS_METADATA,
|
openapi_tags=TAGS_METADATA,
|
||||||
)
|
)
|
||||||
|
|
||||||
app.add_middleware(
|
""" app.add_middleware(
|
||||||
CORSMiddleware,
|
CORSMiddleware,
|
||||||
allow_origins=settings.cors_origins,
|
allow_origins=settings.cors_origins,
|
||||||
allow_methods=["GET", "POST", "PUT", "DELETE"],
|
allow_methods=["GET", "POST", "PUT", "DELETE"],
|
||||||
allow_headers=["*"],
|
allow_headers=["*"],
|
||||||
allow_credentials=True,
|
allow_credentials=True,
|
||||||
)
|
) """
|
||||||
|
|
||||||
|
|
||||||
|
setup_cors(app, mode="open")
|
||||||
|
app.add_middleware(SwaggerAuthMiddleware)
|
||||||
|
app.add_middleware(ApiKeyMiddleware)
|
||||||
|
|
||||||
|
|
||||||
app.include_router(auth_router)
|
app.include_router(auth_router)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue