Spaces:
BG5
/
Running

BG5 commited on
Commit
6ebb4f2
·
verified ·
1 Parent(s): 88aea73

Update fun.py

Browse files
Files changed (1) hide show
  1. fun.py +2 -2
fun.py CHANGED
@@ -7,7 +7,7 @@ import websockets
7
  app = FastAPI()
8
 
9
  TARGET_BASE = "http://127.0.0.1:9222" # 目标服务器(Chrome DevTools)
10
- TARGET_WS_BASE = "ws://127.0.0.1:9222" # WebSocket 目标
11
 
12
  @app.api_route("/{path:path}", methods=["GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS", "HEAD"])
13
  async def proxy(request: Request, path: str):
@@ -39,7 +39,7 @@ async def websocket_proxy(websocket: WebSocket, path: str):
39
  await websocket.accept()
40
  target_url = f"{TARGET_WS_BASE}/{path}"
41
  try:
42
- async with websockets.connect(target_url) as target_ws:
43
  async def client_to_server():
44
  while True:
45
  data = await websocket.receive_text()
 
7
  app = FastAPI()
8
 
9
  TARGET_BASE = "http://127.0.0.1:9222" # 目标服务器(Chrome DevTools)
10
+ TARGET_WS_BASE = "ws://127.0.0.1" # WebSocket 目标
11
 
12
  @app.api_route("/{path:path}", methods=["GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS", "HEAD"])
13
  async def proxy(request: Request, path: str):
 
39
  await websocket.accept()
40
  target_url = f"{TARGET_WS_BASE}/{path}"
41
  try:
42
+ async with websockets.connect(target_url, extra_headers={"Host": "127.0.0.1"}) as target_ws:
43
  async def client_to_server():
44
  while True:
45
  data = await websocket.receive_text()