13 lines
339 B
Python
13 lines
339 B
Python
# app/middleware/cors.py
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
|
|
def add_cors_middleware(app):
|
|
origins = ["*"] # 可以替换为更具体的来源
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=origins,
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|