fix: add CORS middleware to allow specific origins and methods
This commit is contained in:
parent
31d1d8de1e
commit
03831499ca
|
|
@ -10,6 +10,8 @@ from app.api.routes import api_router
|
||||||
from app.core.cache import init_cache, shutdown_cache
|
from app.core.cache import init_cache, shutdown_cache
|
||||||
from app.core.config import settings
|
from app.core.config import settings
|
||||||
from app.core.middleware.cache_monitor import CacheAvailabilityMiddleware
|
from app.core.middleware.cache_monitor import CacheAvailabilityMiddleware
|
||||||
|
from fastapi.middleware.cors import CORSMiddleware
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def create_app() -> FastAPI:
|
def create_app() -> FastAPI:
|
||||||
|
|
@ -25,6 +27,13 @@ def create_app() -> FastAPI:
|
||||||
application = FastAPI(title=settings.project_name, version=settings.version, lifespan=lifespan)
|
application = FastAPI(title=settings.project_name, version=settings.version, lifespan=lifespan)
|
||||||
application.include_router(api_router)
|
application.include_router(api_router)
|
||||||
application.add_middleware(CacheAvailabilityMiddleware)
|
application.add_middleware(CacheAvailabilityMiddleware)
|
||||||
|
app.add_middleware(
|
||||||
|
CORSMiddleware,
|
||||||
|
allow_origins=["https://kitchen-crm.k1nq.tech", "http://192.168.31.51"],
|
||||||
|
allow_credentials=True,
|
||||||
|
allow_methods=["*"], # Разрешить все HTTP-методы
|
||||||
|
allow_headers=["*"], # Разрешить все заголовки
|
||||||
|
)
|
||||||
return application
|
return application
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue