airsltd commited on
Commit
c7aeecd
·
1 Parent(s): 480ecd3
Files changed (1) hide show
  1. proxyserver-fastapi.py +6 -1
proxyserver-fastapi.py CHANGED
@@ -82,12 +82,17 @@ async def proxy_request(url_path: str, request: Request):
82
  # 转发原始请求的头部,排除 'Host' 头部以避免冲突
83
  # FastAPI 的 request.headers 是不可变的,需要转换为字典
84
  headers = {key: value for key, value in request.headers.items() if key.lower() != 'host'}
85
- headers=[]
86
  headers["user-agent"] = "PostmanRuntime/7.45.0"
87
 
88
  # 将检索到的第三方API密钥添加到目标API的请求头中
89
  headers["authorization"] = f"Bearer {third_party_api_key}"
90
  print(f"添加第三方API Key到请求头: Authorization: Bearer {third_party_api_key[:5]}...")
 
 
 
 
 
 
91
 
92
  # 获取请求体
93
  request_body = await request.body()
 
82
  # 转发原始请求的头部,排除 'Host' 头部以避免冲突
83
  # FastAPI 的 request.headers 是不可变的,需要转换为字典
84
  headers = {key: value for key, value in request.headers.items() if key.lower() != 'host'}
 
85
  headers["user-agent"] = "PostmanRuntime/7.45.0"
86
 
87
  # 将检索到的第三方API密钥添加到目标API的请求头中
88
  headers["authorization"] = f"Bearer {third_party_api_key}"
89
  print(f"添加第三方API Key到请求头: Authorization: Bearer {third_party_api_key[:5]}...")
90
+ print(f"请求头部-1: {headers}")
91
+ headers=[]
92
+ print(f"请求头部-2: {headers}")
93
+
94
+
95
+
96
 
97
  # 获取请求体
98
  request_body = await request.body()