airsltd commited on
Commit
9f449e2
·
1 Parent(s): 372baeb
Files changed (1) hide show
  1. proxyserver-fastapi.py +8 -8
proxyserver-fastapi.py CHANGED
@@ -82,7 +82,7 @@ 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["user-agent"] = "PostmanRuntime/7.45.0"
86
 
87
  # 将检索到的第三方API密钥添加到目标API的请求头中
88
  headers["authorization"] = f"Bearer {third_party_api_key}"
@@ -92,15 +92,15 @@ async def proxy_request(url_path: str, request: Request):
92
  print(pretty_json)
93
 
94
 
95
- headers={}
96
- headers["accept"]="*/*"
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"]="PostmanRuntime/7.45.0"
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"
104
 
105
  # headers["x-forwarded-for"]="45.144.242.202"
106
  # headers["x-forwarded-port"]="443"
 
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}"
 
92
  print(pretty_json)
93
 
94
 
95
+ # headers={}
96
+ # headers["accept"]="*/*"
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"
104
 
105
  # headers["x-forwarded-for"]="45.144.242.202"
106
  # headers["x-forwarded-port"]="443"