Skip to content

Commit

Permalink
Merge pull request #42 from CHN-STUDENT/lastest
Browse files Browse the repository at this point in the history
Hmm
  • Loading branch information
spammenotinoz authored Feb 16, 2024
2 parents bc35dbc + fd9f07e commit 556e6cc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
5 changes: 5 additions & 0 deletions Caddyfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 7 additions & 6 deletions backend/api/routers/arkose.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 556e6cc

Please sign in to comment.