airsltd commited on
Commit
61760bc
·
1 Parent(s): e9ee6d7
Files changed (1) hide show
  1. proxyserver-fastapi.py +2 -2
proxyserver-fastapi.py CHANGED
@@ -81,7 +81,7 @@ async def proxy_request(url_path: str, request: Request):
81
 
82
  # 转发原始请求的头部,排除 'Host' 头部以避免冲突
83
  # FastAPI 的 request.headers 是不可变的,需要转换为字典
84
- headers = {key: value for key, value in request.headers.items() if (key.lower() != 'host')&&(key.lower() != 'content-length')}
85
  # headers["user-agent"] = "PostmanRuntime/7.45.0"
86
 
87
  # 将检索到的第三方API密钥添加到目标API的请求头中
@@ -97,7 +97,7 @@ async def proxy_request(url_path: str, request: Request):
97
  # headers["accept-encoding"]="gzip, deflate, br"
98
  # headers["authorization"]=f"Bearer {third_party_api_key}"
99
  # headers["content-type"]="application/json"
100
- # headers["postman-token"]="ad3552d5-c379-4ec0-ae86-9b26cc59bb4b"
101
  headers["user-agent"]="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36"
102
  # headers["x-amzn-trace-id"]="Root=1-68a054e2-78a54d08502e945f387c1952"
103
  # headers["x-direct-url"]="https://airsltd-fastapi-proxy.hf.space/--replicas/pn6yq/v1/https/generativelanguage.googleapis.com/v1beta/openai/chat/completions"
 
81
 
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的请求头中
 
97
  # headers["accept-encoding"]="gzip, deflate, br"
98
  # headers["authorization"]=f"Bearer {third_party_api_key}"
99
  # headers["content-type"]="application/json"
100
+ # # headers["postman-token"]="ad3552d5-c379-4ec0-ae86-9b26cc59bb4b"
101
  headers["user-agent"]="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36"
102
  # headers["x-amzn-trace-id"]="Root=1-68a054e2-78a54d08502e945f387c1952"
103
  # headers["x-direct-url"]="https://airsltd-fastapi-proxy.hf.space/--replicas/pn6yq/v1/https/generativelanguage.googleapis.com/v1beta/openai/chat/completions"