From 058b02b957811a27c9305c6ce0418bc26a2a5894 Mon Sep 17 00:00:00 2001 From: comet Date: Tue, 31 Mar 2026 15:39:11 +0800 Subject: [PATCH 1/2] fix: avoid impersonation for captcha API JSON requests --- src/api/admin.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/api/admin.py b/src/api/admin.py index 25a55da..a074f3e 100644 --- a/src/api/admin.py +++ b/src/api/admin.py @@ -369,11 +369,12 @@ async def _solve_recaptcha_with_api_service( create_url = f"{base_url.rstrip('/')}/createTask" get_url = f"{base_url.rstrip('/')}/getTaskResult" + # Do not use curl_cffi impersonation for captcha API JSON endpoints: some ASGI servers + # (for example FastAPI/Uvicorn) may receive an empty body and return 422. async with AsyncSession() as session: create_resp = await session.post( create_url, json={"clientKey": client_key, "task": task}, - impersonate="chrome120", timeout=30 ) create_json = create_resp.json() @@ -387,7 +388,6 @@ async def _solve_recaptcha_with_api_service( poll_resp = await session.post( get_url, json={"clientKey": client_key, "taskId": task_id}, - impersonate="chrome120", timeout=30 ) poll_json = poll_resp.json() From 1b9634271f54629a32f15636725dba1bfba5ffb9 Mon Sep 17 00:00:00 2001 From: comet Date: Tue, 31 Mar 2026 15:39:17 +0800 Subject: [PATCH 2/2] fix: avoid impersonation for captcha API JSON requests --- src/services/flow_client.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/services/flow_client.py b/src/services/flow_client.py index 18b65c1..4b08868 100644 --- a/src/services/flow_client.py +++ b/src/services/flow_client.py @@ -2397,6 +2397,8 @@ async def _get_api_captcha_token(self, method: str, project_id: str, action: str page_action = action try: + # Do not use curl_cffi impersonation for captcha API JSON endpoints: some ASGI + # servers (for example FastAPI/Uvicorn) may receive an empty body and return 422. async with AsyncSession() as session: create_url = f"{base_url}/createTask" create_data = { @@ -2409,7 +2411,7 @@ async def _get_api_captcha_token(self, method: str, project_id: str, action: str } } - result = await session.post(create_url, json=create_data, impersonate="chrome110") + result = await session.post(create_url, json=create_data) result_json = result.json() task_id = result_json.get('taskId') @@ -2426,7 +2428,7 @@ async def _get_api_captcha_token(self, method: str, project_id: str, action: str "clientKey": client_key, "taskId": task_id } - result = await session.post(get_url, json=get_data, impersonate="chrome110") + result = await session.post(get_url, json=get_data) result_json = result.json() debug_logger.log_info(f"[reCAPTCHA {method}] polling #{i+1}: {result_json}")