kocraft-backend/Craft/middleware/cors_middlewares.py

18 lines
418 B
Python
Raw Permalink Normal View History

2024-07-15 08:47:42 +00:00
import os
from dotenv import find_dotenv, load_dotenv
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
load_dotenv(find_dotenv())
def init_cors_middleware(app: FastAPI):
app.add_middleware(
CORSMiddleware,
allow_origins=os.getenv("CORS_ALLOW_ORIGINS").split(","),
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)