18 lines
418 B
Python
18 lines
418 B
Python
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=["*"],
|
|
)
|
|
|