diff --git a/core/rest_api/api.py b/core/rest_api/api.py index d961d1a..a20b069 100644 --- a/core/rest_api/api.py +++ b/core/rest_api/api.py @@ -5,12 +5,14 @@ import fastapi_gateway_auto_generate from core.config.envs import DICT_ENVS +from fastapi.middleware.cors import CORSMiddleware class API: def __init__(self): self.__app: FastAPI = FastAPI(debug=True) self.__init_routes() + self.__cors_settings() config: fastapi_gateway_auto_generate.Config = fastapi_gateway_auto_generate.Config( fast_api_app=self.__app, @@ -22,6 +24,19 @@ def __init__(self): def __init_routes(self): logger.success("Routers initialized") + def __cors_settings(self): + origins = ["*"] + + self.__app.add_middleware( + CORSMiddleware, + allow_origins=origins, + allow_credentials=True, + allow_methods=["*"], + allow_headers=["*"], + ) + + logger.success("Cors settings are installed") + def run_uvicorn_server(self): run_uvicorn_loguru( uvicorn.Config(