Skip to content

Commit

Permalink
✨ feat: Added cors settings
Browse files Browse the repository at this point in the history
  • Loading branch information
xitowzys committed Apr 4, 2023
1 parent 811db37 commit 9fd882c
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions core/rest_api/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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(
Expand Down

0 comments on commit 9fd882c

Please sign in to comment.