rkihacker commited on
Commit
d5133b1
·
verified ·
1 Parent(s): 98758f0

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +4 -2
main.py CHANGED
@@ -62,7 +62,7 @@ def proxy_deepinfra():
62
  try:
63
  print(f"[INFO] Forwarding POST to {target_url} via {proxy}")
64
 
65
- # 🚫 Ignore user headers completely, always use fixed DeepInfra headers
66
  forward_headers = dict(DEEPINFRA_HEADERS)
67
 
68
  upstream = requests.post(
@@ -83,6 +83,7 @@ def proxy_deepinfra():
83
  headers = dict(upstream.headers)
84
  headers["X-Proxy-Used"] = proxy
85
 
 
86
  return Response(
87
  stream_with_context(generate()),
88
  status=upstream.status_code,
@@ -90,7 +91,8 @@ def proxy_deepinfra():
90
  content_type=upstream.headers.get("Content-Type", "application/json")
91
  )
92
 
93
- except Exception as e:
 
94
  return jsonify({"error": "Proxy failed", "proxy": proxy, "details": str(e)}), 502
95
 
96
  def main():
 
62
  try:
63
  print(f"[INFO] Forwarding POST to {target_url} via {proxy}")
64
 
65
+ # Always use fixed headers (ignore client-supplied headers)
66
  forward_headers = dict(DEEPINFRA_HEADERS)
67
 
68
  upstream = requests.post(
 
83
  headers = dict(upstream.headers)
84
  headers["X-Proxy-Used"] = proxy
85
 
86
+ # 🔑 Return exactly what DeepInfra sent (status, body, headers)
87
  return Response(
88
  stream_with_context(generate()),
89
  status=upstream.status_code,
 
91
  content_type=upstream.headers.get("Content-Type", "application/json")
92
  )
93
 
94
+ except requests.exceptions.RequestException as e:
95
+ # Only if the proxy itself fails (not DeepInfra)
96
  return jsonify({"error": "Proxy failed", "proxy": proxy, "details": str(e)}), 502
97
 
98
  def main():