Spaces:
BG5
/
Running

BG5 commited on
Commit
592b88d
·
verified ·
1 Parent(s): 7027c85

Update fun.py

Browse files
Files changed (1) hide show
  1. fun.py +5 -3
fun.py CHANGED
@@ -14,9 +14,9 @@ async def proxy(request: Request, path: str):
14
 
15
  url = f"{TARGET_BASE}/{path}"
16
  headers = dict(request.headers)
17
-
18
  # 强制 Host 头为 127.0.0.1,避免 Chrome 拒绝
19
- # headers["host"] = "127.0.0.1"
20
  body = await request.body()
21
  async with httpx.AsyncClient(follow_redirects=True) as client:
22
  resp = await client.request(
@@ -26,10 +26,12 @@ async def proxy(request: Request, path: str):
26
  content=body,
27
  params=request.query_params
28
  )
 
 
29
  return Response(
30
  content=resp.content,
31
  status_code=resp.status_code,
32
- headers=dict(resp.headers)
33
  )
34
 
35
  @app.websocket("/{path:path}")
 
14
 
15
  url = f"{TARGET_BASE}/{path}"
16
  headers = dict(request.headers)
17
+ host = headers["host"]
18
  # 强制 Host 头为 127.0.0.1,避免 Chrome 拒绝
19
+ headers["host"] = "127.0.0.1"
20
  body = await request.body()
21
  async with httpx.AsyncClient(follow_redirects=True) as client:
22
  resp = await client.request(
 
26
  content=body,
27
  params=request.query_params
28
  )
29
+ headers = dict(resp.headers)
30
+ headers["host"] = host
31
  return Response(
32
  content=resp.content,
33
  status_code=resp.status_code,
34
+ headers=dheaders
35
  )
36
 
37
  @app.websocket("/{path:path}")