diff --git a/backend/services/proxy.py b/backend/services/proxy.py index ea8e30a..8cdbcde 100644 --- a/backend/services/proxy.py +++ b/backend/services/proxy.py @@ -78,13 +78,21 @@ def username(cfg: dict, session_id: Optional[str] = None) -> str: def playwright_proxy(cfg: dict, session_id: Optional[str] = None) -> Optional[dict]: - """Proxy dict for chromium.launch(proxy=...). None when disabled.""" + """Proxy dict for chromium.launch(proxy=...). None when disabled. + + Credentials are embedded in the server URL rather than passed as separate + fields. Separate fields cause Chromium to wait for a 407 challenge before + sending auth — DataImpulse takes ~14s to issue that challenge, making every + page.goto() timeout. Embedded credentials are sent on the first CONNECT + request, bypassing the round-trip entirely. + """ if not is_enabled(cfg): return None + from urllib.parse import quote + user = quote(username(cfg, session_id), safe='') + pwd = quote(cfg['password'], safe='') return { - 'server': f"http://{cfg['host']}:{cfg['port']}", - 'username': username(cfg, session_id), - 'password': cfg['password'], + 'server': f"http://{user}:{pwd}@{cfg['host']}:{cfg['port']}", }