Skip to content

Commit

Permalink
fix: 调整部分细节
Browse files Browse the repository at this point in the history
  • Loading branch information
liuhuapiaoyuan committed Mar 2, 2024
1 parent b30f4ba commit eed4abb
Show file tree
Hide file tree
Showing 23 changed files with 82 additions and 33 deletions.
37 changes: 18 additions & 19 deletions api/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ func Index(r *ghttp.Request) {
"pageProps": {
"user": {
"id": "user-xyhelper",
"name": "admin@openai.com",
"email": "admin@openai.com",
"name": "admin@closeai.com",
"email": "admin@closeai.com",
"image": "/avatars.png",
"picture": "/avatars.png",
"idp": "auth0",
Expand Down Expand Up @@ -86,8 +86,8 @@ func C(r *ghttp.Request) {
"pageProps": {
"user": {
"id": "user-xyhelper",
"name": "admin@openai.com",
"email": "admin@openai.com",
"name": "admin@closeai.com",
"email": "admin@closeai.com",
"image": "/avatars.png",
"picture": "/avatars.png",
"idp": "auth0",
Expand Down Expand Up @@ -142,8 +142,8 @@ func Gpts(r *ghttp.Request) {
"pageProps": {
"user": {
"id": "user-xyhelper",
"name": "admin@openai.com",
"email": "admin@openai.com",
"name": "admin@closeai.com",
"email": "admin@closeai.com",
"image": "/avatars.png",
"picture": "/avatars.png",
"idp": "auth0",
Expand Down Expand Up @@ -195,8 +195,8 @@ func Discovery(r *ghttp.Request) {
"pageProps": {
"user": {
"id": "user-xyhelper",
"name": "admin@openai.com",
"email": "admin@openai.com",
"name": "admin@closeai.com",
"email": "admin@closeai.com",
"image": "/avatars.png",
"picture": "/avatars.png",
"idp": "auth0",
Expand Down Expand Up @@ -249,8 +249,8 @@ func Editor(r *ghttp.Request) {
"pageProps": {
"user": {
"id": "user-xyhelper",
"name": "admin@openai.com",
"email": "admin@openai.com",
"name": "admin@closeai.com",
"email": "admin@closeai.com",
"image": "/avatars.png",
"picture": "/avatars.png",
"idp": "auth0",
Expand Down Expand Up @@ -311,8 +311,8 @@ func Slug(r *ghttp.Request) {
"pageProps": {
"user": {
"id": "user-xyhelper",
"name": "admin@openai.com",
"email": "admin@openai.com",
"name": "admin@closeai.com",
"email": "admin@closeai.com",
"image": "/avatars.png",
"picture": "/avatars.png",
"idp": "auth0",
Expand Down Expand Up @@ -370,8 +370,8 @@ func G(r *ghttp.Request) {
"gizmo": null,
"user": {
"id": "user-xyhelper",
"name": "admin@openai.com",
"email": "admin@openai.com",
"name": "admin@closeai.com",
"email": "admin@closeai.com",
"image": "/avatars.png",
"picture": "/avatars.png",
"idp": "auth0",
Expand Down Expand Up @@ -411,7 +411,6 @@ func G(r *ghttp.Request) {
})
}

// GC 游戏会话
func GC(r *ghttp.Request) {

if r.Session.MustGet("offical-session").IsEmpty() {
Expand All @@ -428,8 +427,8 @@ func GC(r *ghttp.Request) {
"pageProps": {
"user": {
"id": "user-xyhelper",
"name": "admin@openai.com",
"email": "admin@openai.com",
"name": "admin@closeai.com",
"email": "admin@closeai.com",
"image": "/avatars.png",
"picture": "/avatars.png",
"idp": "auth0",
Expand Down Expand Up @@ -485,8 +484,8 @@ func Mine(r *ghttp.Request) {
"pageProps": {
"user": {
"id": "user-xyhelper",
"name": "admin@openai.com",
"email": "admin@openai.com",
"name": "admin@closeai.com",
"email": "admin@closeai.com",
"image": "/avatars.png",
"picture": "/avatars.png",
"idp": "auth0",
Expand Down
4 changes: 2 additions & 2 deletions api/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func Session(r *ghttp.Request) {
sessionJson.Set("accessToken", record["officialSession"].String())
service.AccessTokenCache.Set(ctx, userToken.String(), sessionJson.Get("accessToken").String(), 10*24*time.Hour)
sessionJson.Set("accessToken", userToken.String())
sessionJson.Set("user.email", "admin@openai.com")
sessionJson.Set("user.email", "admin@closeai.com")
sessionJson.Set("user.name", expireTime)
sessionJson.Set("user.image", "/avatars.png")
sessionJson.Set("user.picture", "/avatars.png")
Expand Down Expand Up @@ -85,7 +85,7 @@ func Session(r *ghttp.Request) {

service.AccessTokenCache.Set(ctx, userToken.String(), sessionJson.Get("accessToken").String(), 10*24*time.Hour)
sessionJson.Set("accessToken", userToken.String())
sessionJson.Set("user.email", "admin@openai.com")
sessionJson.Set("user.email", "admin@closeai.com")
sessionJson.Set("user.name", expireTime)
sessionJson.Set("user.image", "/avatars.png")
sessionJson.Set("user.picture", "/avatars.png")
Expand Down
4 changes: 2 additions & 2 deletions backend-api/backend-api.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func init() {
s := g.Server()
s.BindHandler("/backend-api/*any", ProxyAll)
// s.BindHandler("/public-api/*any", ProxyAll)
// s.BindHandler("/_next/data/*any", NextDataGptsFixed)
//s.BindHandler("/_next/data/*any", NextDataGptsFixed)
backendGroup := s.Group("/backend-api")
backendGroup.POST("/accounts/data_export", NotFound) // 禁用导出
backendGroup.POST("/payments/checkout", NotFound) // 禁用支付
Expand Down Expand Up @@ -109,7 +109,7 @@ func ProxyAll(r *ghttp.Request) {
}

// 判断response的Cotnent-Type是否是json
if response.Header.Get("Content-Type") == "application/json" {
if strings.Contains(response.Header.Get("Content-Type"), "json") {
isStream = false
}
if isCreateConversation {
Expand Down
6 changes: 3 additions & 3 deletions backend-api/me.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ func Me(r *ghttp.Request) {
return
}
resJson := gjson.New(resStr)
resJson.Set("email", "admin@openai.com")
resJson.Set("email", "__mirror@closeai.com")
resJson.Set("name", record["user_username"].String())
resJson.Set("picture", "/avatars.png")
resJson.Set("phone_number", "+1911")
resJson.Set("orgs.data.0.description", "OpenAI")
resJson.Set("phone_number", "+1911011")
resJson.Set("orgs.data.0.description", "closeai")
// resJson.Dump()
r.Response.WriteJson(resJson)
}
43 changes: 38 additions & 5 deletions backend-api/next_data_gpts_fixed.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,47 @@
package backendapi

import (
"github.com/gogf/gf/v2/encoding/gjson"
"chatgpt-mirror-server/config"
"crypto/tls"
"net/http"
"net/http/httputil"
"net/url"

"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/net/ghttp"
)

func NextDataGptsFixed(r *ghttp.Request) {
ctx := r.GetCtx()

// 如果请求包含gizmoId
gizmoId := r.Request.URL.Query().Get("gizmoId")
if gizmoId != "" {
UpStream := config.CHATPROXY(ctx)
u, _ := url.Parse(UpStream)
proxy := httputil.NewSingleHostReverseProxy(u)
proxy.Transport = &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
}
proxy.ErrorHandler = func(writer http.ResponseWriter, request *http.Request, e error) {
g.Log().Error(ctx, e)
writer.WriteHeader(http.StatusBadGateway)
}
newreq := r.Request.Clone(ctx)
newreq.URL.Host = u.Host
newreq.URL.Scheme = u.Scheme
newreq.Host = u.Host
newreq.Header.Set("authkey", config.AUTHKEY(ctx))

newreq.Header.Set("Host", "chat.openai.com")
newreq.Header.Set("Origin", "https://chat.openai.com/chat")
proxy.ServeHTTP(r.Response.Writer.RawWriter(), newreq)
return

}

resJson := gjson.New(`
{ }
`)
r.Response.WriteJson(resJson)
// r.Response.Header().Set("X-Client-Source", "explorer")
// r.Response.Header().Set("X-Middleware-Skip", "1")
// r.Response.Header().Set("Access-Control-Allow-Headers", "Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization, accept, origin, Cache-Control, X-Requested-With")
// r.Response.Write(`{}`)
}
3 changes: 2 additions & 1 deletion config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,6 @@ ONLYTOKEN: false
CDNHOST: "https://file.chatgpt.ggss.club"
ASSET_PREFIX: "https://cdn.chatgpt.ggss.club"
# websocket服务地址
WS_SERVICE: "ws://127.0.0.1:7999"
WS_SERVICE: "wss://chatgpt.ggss.club/ws"
#WS_SERVICE: "ws://127.0.0.1:7999"
# 5a07e29c-31d8-4976-ba66-f183598587d9
2 changes: 1 addition & 1 deletion frontend/stats.html

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions resource/template/0qzbhV8iuN7gm3Mz5VXc9/chat.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!DOCTYPE html><html data-build="prod-da51a0d"><head>{{.envScript}}<meta charSet="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" /><link rel="apple-touch-icon" sizes="180x180" href="{{.assetPrefix}}/_next/static/media/apple-touch-icon.59f2e898.png" /><link rel="icon" type="image/png" sizes="32x32" href="{{.assetPrefix}}/_next/static/media/favicon-32x32.be48395e.png" /><link rel="icon" type="image/png" sizes="16x16" href="{{.assetPrefix}}/_next/static/media/favicon-16x16.9b8dbb69.png" /><link rel="preconnect" href="{{.assetPrefix}}" /><title>ChatGPT</title><meta name="title" content="ChatGPT: Get instant answers, find inspiration, learn something new" /><meta name="description" content="ChatGPT is a free-to-use AI system. Use it for engaging conversations, gain insights, automate tasks, and witness the future of AI, all in one place." /><meta name="keywords" content="ai chat,ai,chap gpt,chat gbt,chat gpt 3,chat gpt login,chat gpt website,chat gpt,chat gtp,chat openai,chat,chatai,chatbot gpt,chatg,chatgpt login,chatgpt,gpt chat,open ai,openai chat,openai chatgpt,openai" /><meta property="og:description" content="A conversational AI system that listens, learns, and challenges" /><meta name="robots" content="index, follow" /><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><meta property="og:title" content="ChatGPT" /><meta property="og:image" content="{{.assetPrefix}}/_next/static/media/chatgpt-share-og.49cbbffe.png" /><meta property="og:url" content="https://chat.openai.com" /><meta name="apple-itunes-app" content="app-id=6448311069" /><meta name="next-head-count" content="17" /><link rel="preload" href="{{.assetPrefix}}/_next/static/media/soehne-buch.13189857.woff2" as="font" crossorigin /><link rel="preload" href="{{.assetPrefix}}/_next/static/media/soehne-halbfett.977f1845.woff2" as="font" crossorigin /><link rel="preload" href="{{.assetPrefix}}/_next/static/media/soehne-mono-buch.de677af1.woff2" as="font" crossorigin /><link rel="preload" href="{{.assetPrefix}}/_next/static/media/soehne-mono-halbfett.b082e8e2.woff2" as="font" crossorigin /><link data-next-font rel="preconnect" href="/" crossorigin="anonymous" /><link rel="preload" href="{{.assetPrefix}}/_next/static/css/139314fdaaf90d91.css" as="style" crossorigin="anonymous" /><link rel="stylesheet" href="{{.assetPrefix}}/_next/static/css/139314fdaaf90d91.css" crossorigin="anonymous" data-n-g /><noscript data-n-css></noscript><script defer crossorigin="anonymous" nomodule src="{{.assetPrefix}}/_next/static/chunks/polyfills-c67a75d1b6f99dc8.js"></script><script src="{{.assetPrefix}}/_next/static/chunks/webpack-18c779c212d344ed.js" defer crossorigin="anonymous"></script><script src="{{.assetPrefix}}/_next/static/chunks/framework-31ffa51d236da229.js" defer crossorigin="anonymous"></script><script src="{{.assetPrefix}}/_next/static/chunks/main-6da2aad3a6c32aae.js" defer crossorigin="anonymous"></script><script src="{{.assetPrefix}}/_next/static/chunks/pages/_app-5fb664d9212b2842.js" defer crossorigin="anonymous"></script><script src="{{.assetPrefix}}/_next/static/chunks/pages/%5B%5B...default%5D%5D-6395e1f389afa57e.js" defer crossorigin="anonymous"></script><script src="{{.assetPrefix}}/_next/static/0qzbhV8iuN7gm3Mz5VXc9/_buildManifest.js" defer crossorigin="anonymous"></script><script src="{{.assetPrefix}}/_next/static/0qzbhV8iuN7gm3Mz5VXc9/_ssgManifest.js" defer crossorigin="anonymous"></script></head><body class="antialiased"><div id="__next"><script>!function(){try{var d=document.documentElement,c=d.classList;c.remove('light','dark');var e=localStorage.getItem('theme');if('system'===e||(!e&&true)){var t='(prefers-color-scheme: dark)',m=window.matchMedia(t);if(m.media!==t||m.matches){d.style.colorScheme = 'dark';c.add('dark')}else{d.style.colorScheme = 'light';c.add('light')}}else if(e){c.add(e|| '')}if(e==='light'||e==='dark')d.style.colorScheme=e}catch(e){}}()</script><div class="relative z-0 flex h-full w-full overflow-hidden"><div class="relative flex h-full max-w-full flex-1 flex-col overflow-hidden"><main class="relative h-full w-full flex-1 overflow-auto transition-width"></main></div></div><div class="absolute left-0 right-0 top-0 z-[2]"></div><audio class="fixed bottom-0 left-0 hidden h-0 w-0" autoplay crossorigin="anonymous"></audio></div><script id="__NEXT_DATA__" type="application/json" crossorigin="anonymous">{{.props}}</script><script></script></body></html>
1 change: 1 addition & 0 deletions resource/template/0qzbhV8iuN7gm3Mz5VXc9/discovery.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!DOCTYPE html><html data-build="prod-da51a0d"><head>{{.envScript}}<meta charSet="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" /><link rel="apple-touch-icon" sizes="180x180" href="{{.assetPrefix}}/_next/static/media/apple-touch-icon.59f2e898.png" /><link rel="icon" type="image/png" sizes="32x32" href="{{.assetPrefix}}/_next/static/media/favicon-32x32.be48395e.png" /><link rel="icon" type="image/png" sizes="16x16" href="{{.assetPrefix}}/_next/static/media/favicon-16x16.9b8dbb69.png" /><link rel="preconnect" href="{{.assetPrefix}}" /><title>ChatGPT</title><meta name="title" content="ChatGPT: Get instant answers, find inspiration, learn something new" /><meta name="description" content="ChatGPT is a free-to-use AI system. Use it for engaging conversations, gain insights, automate tasks, and witness the future of AI, all in one place." /><meta name="keywords" content="ai chat,ai,chap gpt,chat gbt,chat gpt 3,chat gpt login,chat gpt website,chat gpt,chat gtp,chat openai,chat,chatai,chatbot gpt,chatg,chatgpt login,chatgpt,gpt chat,open ai,openai chat,openai chatgpt,openai" /><meta property="og:description" content="A conversational AI system that listens, learns, and challenges" /><meta name="robots" content="index, follow" /><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><meta property="og:title" content="ChatGPT" /><meta property="og:image" content="{{.assetPrefix}}/_next/static/media/chatgpt-share-og.49cbbffe.png" /><meta property="og:url" content="https://chat.openai.com" /><meta name="apple-itunes-app" content="app-id=6448311069" /><meta name="next-head-count" content="17" /><link rel="preload" href="{{.assetPrefix}}/_next/static/media/soehne-buch.13189857.woff2" as="font" crossorigin /><link rel="preload" href="{{.assetPrefix}}/_next/static/media/soehne-halbfett.977f1845.woff2" as="font" crossorigin /><link rel="preload" href="{{.assetPrefix}}/_next/static/media/soehne-mono-buch.de677af1.woff2" as="font" crossorigin /><link rel="preload" href="{{.assetPrefix}}/_next/static/media/soehne-mono-halbfett.b082e8e2.woff2" as="font" crossorigin /><link data-next-font rel="preconnect" href="/" crossorigin="anonymous" /><link rel="preload" href="{{.assetPrefix}}/_next/static/css/139314fdaaf90d91.css" as="style" crossorigin="anonymous" /><link rel="stylesheet" href="{{.assetPrefix}}/_next/static/css/139314fdaaf90d91.css" crossorigin="anonymous" data-n-g /><noscript data-n-css></noscript><script defer crossorigin="anonymous" nomodule src="{{.assetPrefix}}/_next/static/chunks/polyfills-c67a75d1b6f99dc8.js"></script><script src="{{.assetPrefix}}/_next/static/chunks/webpack-18c779c212d344ed.js" defer crossorigin="anonymous"></script><script src="{{.assetPrefix}}/_next/static/chunks/framework-31ffa51d236da229.js" defer crossorigin="anonymous"></script><script src="{{.assetPrefix}}/_next/static/chunks/main-6da2aad3a6c32aae.js" defer crossorigin="anonymous"></script><script src="{{.assetPrefix}}/_next/static/chunks/pages/_app-5fb664d9212b2842.js" defer crossorigin="anonymous"></script><script src="{{.assetPrefix}}/_next/static/chunks/pages/gpts-2c9ed3f17744c8c4.js" defer crossorigin="anonymous"></script><script src="{{.assetPrefix}}/_next/static/0qzbhV8iuN7gm3Mz5VXc9/_buildManifest.js" defer crossorigin="anonymous"></script><script src="{{.assetPrefix}}/_next/static/0qzbhV8iuN7gm3Mz5VXc9/_ssgManifest.js" defer crossorigin="anonymous"></script></head><body class="antialiased"><div id="__next"><script>!function(){try{var d=document.documentElement,c=d.classList;c.remove('light','dark');var e=localStorage.getItem('theme');if('system'===e||(!e&&true)){var t='(prefers-color-scheme: dark)',m=window.matchMedia(t);if(m.media!==t||m.matches){d.style.colorScheme = 'dark';c.add('dark')}else{d.style.colorScheme = 'light';c.add('light')}}else if(e){c.add(e|| '')}if(e==='light'||e==='dark')d.style.colorScheme=e}catch(e){}}()</script><div class="absolute left-0 right-0 top-0 z-[2]"></div><audio class="fixed bottom-0 left-0 hidden h-0 w-0" autoplay crossorigin="anonymous"></audio></div><script id="__NEXT_DATA__" type="application/json" crossorigin="anonymous">{{.props}}</script><script></script></body></html>
Loading

0 comments on commit eed4abb

Please sign in to comment.