This commit is contained in:
hackrobot
2024-07-15 22:03:11 +08:00
parent 6fa209518e
commit ddad2bb1b2
2 changed files with 7 additions and 4 deletions

View File

@@ -14,12 +14,13 @@ app = FastAPI()
# 允许所有来源跨域访问(不推荐用于生产环境)
origins = ["*"]
# 设置CORS跨域资源共享策略
app.add_middleware(
CORSMiddleware,
allow_origins=origins,
allow_origins=["*"], # 允许所有来源
allow_credentials=True,
allow_methods=["*"], # 允许所有HTTP方法
allow_headers=["*"], # 允许所有HTTP
allow_methods=["*"], # 允许所有方法
allow_headers=["*"], # 允许所有请求
)
# 依赖注入
def get_db():