mirror of
https://github.com/lanqian528/chat2api.git
synced 2026-06-13 21:02:46 +08:00
v1.6.7-beta4 fix bugs
This commit is contained in:
parent
0eb868d612
commit
e481d7fbe5
@ -38,7 +38,7 @@ if enable_gateway:
|
||||
return await login_html(request)
|
||||
|
||||
user_remix_context = remix_context.copy()
|
||||
set_value_for_key(user_remix_context, "user", {"id": "user-chatgpt"})
|
||||
set_value_for_key(user_remix_context, "user", {})
|
||||
set_value_for_key(user_remix_context, "accessToken", token)
|
||||
|
||||
response = templates.TemplateResponse("chatgpt.html", {"request": request, "remix_context": user_remix_context})
|
||||
@ -296,6 +296,9 @@ if enable_gateway:
|
||||
|
||||
@app.api_route("/{path:path}", methods=["GET", "POST", "PUT", "DELETE", "OPTIONS", "HEAD", "PATCH", "TRACE"])
|
||||
async def reverse_proxy(request: Request, path: str):
|
||||
if re.match("/v1/rgstr", path):
|
||||
return Response(status_code=202, content=b'{"success":true}')
|
||||
|
||||
if re.match("ces/v1", path):
|
||||
return {"success": True}
|
||||
|
||||
|
||||
@ -148,6 +148,8 @@ async def chatgpt_reverse_proxy(request: Request, path: str):
|
||||
base_url = "https://cdn.oaistatic.com"
|
||||
if "file-" in path and "backend-api" not in path:
|
||||
base_url = "https://files.oaiusercontent.com"
|
||||
if "v1/" in path:
|
||||
base_url = "https://ab.chatgpt.com"
|
||||
|
||||
token = request.cookies.get("token", "")
|
||||
req_token = await get_real_req_token(token)
|
||||
@ -199,9 +201,14 @@ async def chatgpt_reverse_proxy(request: Request, path: str):
|
||||
response = Response(content=(await r.atext()), media_type=r.headers.get("content-type"),
|
||||
status_code=r.status_code, background=background)
|
||||
else:
|
||||
content = ((await r.atext()).replace("chatgpt.com", origin_host)
|
||||
content = await r.atext()
|
||||
if "initialize" in content:
|
||||
pass
|
||||
content = (content
|
||||
.replace("ab.chatgpt.com", origin_host)
|
||||
.replace("cdn.oaistatic.com", origin_host)
|
||||
# .replace("files.oaiusercontent.com", origin_host)
|
||||
.replace("chatgpt.com", origin_host)
|
||||
.replace("https", petrol))
|
||||
rheaders = dict(r.headers)
|
||||
content_type = rheaders.get("content-type", "")
|
||||
|
||||
@ -1 +1 @@
|
||||
1.6.7-beta3
|
||||
1.6.7-beta4
|
||||
Loading…
Reference in New Issue
Block a user