baoyubo 3 dienas atpakaļ
vecāks
revīzija
c9ef4a8134
1 mainītis faili ar 6 papildinājumiem un 0 dzēšanām
  1. 6 0
      routers/api/gateway/skwhp_api.py

+ 6 - 0
routers/api/gateway/skwhp_api.py

@@ -4,6 +4,7 @@ from fastapi import APIRouter, Request, HTTPException, Response
 import requests
 import asyncio
 import json
+import traceback
 from extensions import logger
 
 TARGET_BASE_URL = "http://172.26.1.85:8530/api"
@@ -26,6 +27,8 @@ def sync_fetch(method, url, params=None, headers=None, data=None):
             headers=dict(response.headers)
         )
     except Exception as e:
+
+        traceback.print_exc()
         raise Exception(f"Requests error: {str(e)}")
 
 @router.api_route("/skwhp/{path:path}", methods=["GET", "POST", "PUT", "DELETE", "PATCH"])
@@ -41,6 +44,7 @@ async def proxy(request: Request, path: str):
         try:
             body = await request.body()
         except:
+            traceback.print_exc()
             body = None
 
         try:
@@ -51,6 +55,7 @@ async def proxy(request: Request, path: str):
                     data = json.loads(data)
                     logger.info(data)
         except:
+            traceback.print_exc()
             pass
 
     # 使用 asyncio.to_thread 在后台线程中运行同步的 requests 调用
@@ -65,4 +70,5 @@ async def proxy(request: Request, path: str):
         )
         return response
     except Exception as e:
+        traceback.print_exc()
         raise HTTPException(status_code=500, detail=f"代理请求失败: {str(e)}")