Merge branch 'main' of https://github.com/DiskNext/Server
This commit is contained in:
12
main.py
12
main.py
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user