This commit is contained in:
2026-01-13 15:30:57 +08:00
28 changed files with 811 additions and 201 deletions

12
main.py
View File

@@ -42,6 +42,18 @@ app.add_middleware(
allow_methods=["*"],
allow_headers=["*"],
)
=======
# 添加跨域 CORS 中间件,仅在调试模式下启用,以允许所有来源访问 API
if appmeta.debug:
from fastapi.middleware.cors import CORSMiddleware
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
>>>>>>> d2c914cff89e566b0b7ab7a2655ae72905f888f5
@app.exception_handler(Exception)
async def handle_unexpected_exceptions(request: Request, exc: Exception) -> NoReturn: