feat(api): 添加跨域资源共享 (CORS) 中间件
This commit is contained in:
@@ -3,6 +3,7 @@ from pydantic import BaseModel, Field
|
||||
from typing import Dict, Any, List, Optional, Literal
|
||||
from datetime import datetime
|
||||
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
|
||||
from app.core import Config, logger
|
||||
|
||||
@@ -12,6 +13,14 @@ app = FastAPI(
|
||||
version="1.0.0",
|
||||
)
|
||||
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=["*"], # 允许所有域名跨域访问
|
||||
allow_credentials=True,
|
||||
allow_methods=["*"], # 允许所有请求方法,如 GET、POST、PUT、DELETE
|
||||
allow_headers=["*"], # 允许所有请求头
|
||||
)
|
||||
|
||||
# 此文件由ai生成 返回值非最终版本
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user