From 87f753906c5074d0a2868eabb34e1d27c89a7991 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=98zh=E2=80=99?= Date: Fri, 16 Feb 2024 17:06:44 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E9=BB=98=E8=AE=A4=E6=B7=BB=E5=8A=A0=20Refe?= =?UTF-8?q?rer=EF=BC=8C=E9=81=BF=E5=85=8D=20ninja=20=E6=8A=A5=20500=20?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/api/routers/arkose.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/backend/api/routers/arkose.py b/backend/api/routers/arkose.py index a301f5e9..74c093e3 100644 --- a/backend/api/routers/arkose.py +++ b/backend/api/routers/arkose.py @@ -82,10 +82,12 @@ async def forward_arkose_request(request: Request, path: str): referer = request.headers.get("referer") origin = request.headers.get("origin") - if referer and "/arkose/p/" in referer: - referer_path = referer.split("/arkose/p/", maxsplit=1)[1] - referer = f"{config.openai_web.arkose_endpoint_base}{referer_path}" - origin = extract_origin(referer) + # if referer and "/arkose/p/" in referer: + # referer_path = referer.split("/arkose/p/", maxsplit=1)[1] + # referer = f"{config.openai_web.arkose_endpoint_base}{referer_path}" + # origin = extract_origin(referer) + if not referer: + referer = f"{config.openai_web.arkose_endpoint_base}" # 检查是否有cookie,如果有,则处理并添加到headers中 cookie = request.headers.get("cookie") @@ -117,7 +119,6 @@ async def forward_arkose_request(request: Request, path: str): headers['Content-Type'] = 'application/x-www-form-urlencoded; charset=UTF-8' blob_data = None blob_object = None - try: request_to_send = httpx.Request(method, f"{config.openai_web.arkose_endpoint_base}{path}", headers=headers, content=modified_data_bytes, params=dict(request.query_params)) @@ -175,7 +176,7 @@ async def get_arkose_info(request: Request, _user: User = Depends(current_active async with httpx.AsyncClient() as client: response = await client.post(f"{config.openai_web.arkose_endpoint_base}backend-api/sentinel/arkose/dx", headers=headers) - print(response.json()) + # print(response.json()) # 检查请求是否成功 if response.status_code == 200: response_data = response.json() From fd9f07e4ade1c2a38cc70bd02035b4fb277798be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=98zh=E2=80=99?= Date: Fri, 16 Feb 2024 17:08:35 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BB=A3=E7=90=86=20cdn?= =?UTF-8?q?=20=E8=B7=AF=E5=BE=84=EF=BC=8C=E5=8F=AF=E8=83=BD=E4=BC=9A?= =?UTF-8?q?=E9=81=87=E5=88=B0=E9=AA=8C=E8=AF=81=E7=A0=81=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E5=8A=A0=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Caddyfile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Caddyfile b/Caddyfile index 3aa13ef3..2830eff2 100644 --- a/Caddyfile +++ b/Caddyfile @@ -10,6 +10,11 @@ reverse_proxy localhost:8000 } + handle_path /cdn/* { + rewrite * /api/arkose/p/cdn{path} + reverse_proxy localhost:8000 + } + handle_path /fc/* { rewrite * /api/arkose/p/fc{path} reverse_proxy localhost:8000