Spaces:
Sleeping
Sleeping
update
Browse files- proxyserver-fastapi.py +2 -2
proxyserver-fastapi.py
CHANGED
|
@@ -82,10 +82,10 @@ 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 |
|
| 87 |
# 将检索到的第三方API密钥添加到目标API的请求头中
|
| 88 |
-
headers["
|
| 89 |
print(f"添加第三方API Key到请求头: Authorization: Bearer {third_party_api_key[:5]}...")
|
| 90 |
|
| 91 |
# 获取请求体
|
|
|
|
| 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 |
|
| 91 |
# 获取请求体
|