From 233c86f1bd165b142595b3b8223578a4cef5f329 Mon Sep 17 00:00:00 2001 From: GCSLaoLi Date: Mon, 18 Dec 2023 00:24:09 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=8E=8B=E7=BC=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/next.go | 7 ++++++- config.yaml | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/api/next.go b/api/next.go index deea325..9cd8b83 100644 --- a/api/next.go +++ b/api/next.go @@ -17,13 +17,18 @@ import ( func ProxyNext(r *ghttp.Request) { ctx := r.Context() officalSession := gjson.New(r.Session.MustGet("offical-session")) - refreshCookie := officalSession.Get("refreshToken").String() + refreshCookie := officalSession.Get("refreshCookie").String() u, _ := url.Parse(config.CHATPROXY(ctx)) proxy := httputil.NewSingleHostReverseProxy(u) proxy.ErrorHandler = func(writer http.ResponseWriter, request *http.Request, e error) { writer.WriteHeader(http.StatusBadGateway) } req := r.Request.Clone(ctx) + req.URL.Host = u.Host + req.URL.Scheme = u.Scheme + req.Host = u.Host + // 去除header 中的 压缩 + req.Header.Del("Accept-Encoding") // 替换path 中的 cacheBuildId 为 buildId req.URL.Path = gstr.Replace(req.URL.Path, config.CacheBuildId, config.BuildId, 1) req.Header.Set("Cookie", "__Secure-next-auth.session-token="+refreshCookie) diff --git a/config.yaml b/config.yaml index 8a98d77..8b38cee 100644 --- a/config.yaml +++ b/config.yaml @@ -56,8 +56,8 @@ modules: enable: 1 # 接入网关地址 -CHATPROXY: "https://demo.xyhelper.cn" -# CHATPROXY: "http://172.17.0.1:7009" +# CHATPROXY: "https://demo.xyhelper.cn" +CHATPROXY: "https://chatproxy-dev.closeai.biz" # 接入网关的authkey AUTHKEY: "xyhelper" ONLYTOKEN: true From 2aeb536128b1fda191652d645a53d8282552fb31 Mon Sep 17 00:00:00 2001 From: abc Date: Thu, 11 Jan 2024 09:40:45 +0800 Subject: [PATCH 2/4] =?UTF-8?q?feat:=20=E9=80=82=E9=85=8D=E6=9C=80?= =?UTF-8?q?=E6=96=B0=E7=9A=84gpts=20store=20fix:=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E7=82=B9=E5=87=BBgpts=E9=A1=B5=E9=9D=A2=E7=99=BD=E5=B1=8F?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend-api/backend-api.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/backend-api/backend-api.go b/backend-api/backend-api.go index 468f754..764910b 100644 --- a/backend-api/backend-api.go +++ b/backend-api/backend-api.go @@ -28,7 +28,8 @@ var ( func init() { s := g.Server() s.BindHandler("/backend-api/*any", ProxyAll) - s.BindHandler("/_next/data/*any", NextDataGptsFixed) + s.BindHandler("/public-api/*any", ProxyAll) + // s.BindHandler("/_next/data/*any", NextDataGptsFixed) backendGroup := s.Group("/backend-api") backendGroup.POST("/accounts/data_export", NotFound) // 禁用导出 backendGroup.POST("/payments/checkout", NotFound) // 禁用支付 From 820ec93819a22236516407ebf30d7373db5ca185 Mon Sep 17 00:00:00 2001 From: GCSLaoLi Date: Fri, 12 Jan 2024 10:26:36 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E9=80=82=E9=85=8Dteam?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/api.go | 3 +- api/index.go | 69 ++++++++++++++++--- backend-api/backend-api.go | 53 ++++++++------ config.yaml | 4 +- main.go | 1 + public-api/proxypublic.go | 29 ++++++++ public-api/public-api.go | 9 +++ .../template/Rp5H7oULko6u7cJEjMucd/chat.html | 1 + .../Rp5H7oULko6u7cJEjMucd/discovery.html | 1 + .../Rp5H7oULko6u7cJEjMucd/editor.html | 1 + .../template/Rp5H7oULko6u7cJEjMucd/g.html | 1 + .../template/Rp5H7oULko6u7cJEjMucd/gc.html | 1 + .../template/Rp5H7oULko6u7cJEjMucd/gpts.html | 1 + .../template/Rp5H7oULko6u7cJEjMucd/mine.html | 1 + .../template/Rp5H7oULko6u7cJEjMucd/slug.html | 1 + .../template/WtU07IOQoMFgLEFUvpFfy/chat.html | 1 + .../WtU07IOQoMFgLEFUvpFfy/discovery.html | 1 + .../WtU07IOQoMFgLEFUvpFfy/editor.html | 1 + .../template/WtU07IOQoMFgLEFUvpFfy/g.html | 1 + .../template/WtU07IOQoMFgLEFUvpFfy/gc.html | 1 + .../template/WtU07IOQoMFgLEFUvpFfy/mine.html | 1 + .../template/WtU07IOQoMFgLEFUvpFfy/slug.html | 1 + 22 files changed, 151 insertions(+), 32 deletions(-) create mode 100644 public-api/proxypublic.go create mode 100644 public-api/public-api.go create mode 100644 resource/template/Rp5H7oULko6u7cJEjMucd/chat.html create mode 100644 resource/template/Rp5H7oULko6u7cJEjMucd/discovery.html create mode 100644 resource/template/Rp5H7oULko6u7cJEjMucd/editor.html create mode 100644 resource/template/Rp5H7oULko6u7cJEjMucd/g.html create mode 100644 resource/template/Rp5H7oULko6u7cJEjMucd/gc.html create mode 100644 resource/template/Rp5H7oULko6u7cJEjMucd/gpts.html create mode 100644 resource/template/Rp5H7oULko6u7cJEjMucd/mine.html create mode 100644 resource/template/Rp5H7oULko6u7cJEjMucd/slug.html create mode 100644 resource/template/WtU07IOQoMFgLEFUvpFfy/chat.html create mode 100644 resource/template/WtU07IOQoMFgLEFUvpFfy/discovery.html create mode 100644 resource/template/WtU07IOQoMFgLEFUvpFfy/editor.html create mode 100644 resource/template/WtU07IOQoMFgLEFUvpFfy/g.html create mode 100644 resource/template/WtU07IOQoMFgLEFUvpFfy/gc.html create mode 100644 resource/template/WtU07IOQoMFgLEFUvpFfy/mine.html create mode 100644 resource/template/WtU07IOQoMFgLEFUvpFfy/slug.html diff --git a/api/api.go b/api/api.go index d9316e1..f772603 100644 --- a/api/api.go +++ b/api/api.go @@ -30,7 +30,8 @@ func init() { group.GET("/gpts/editor", Editor) group.GET("/gpts/editor/:slug", Slug) group.GET("/g/:gizmoId/c/:convId", GC) - group.GET(("/gpts/mine"), Mine) + group.GET("/gpts/mine", Mine) + group.GET("/gpts", Gpts) s.BindHandler("/_next/data/*any", ProxyNext) diff --git a/api/index.go b/api/index.go index bb48cdd..8e72499 100644 --- a/api/index.go +++ b/api/index.go @@ -60,7 +60,7 @@ func Index(r *ghttp.Request) { if model != "" { propsJson.Set("query.model", model) } - propsJson.Set("buildId", config.CacheBuildId) + propsJson.Set("buildId", config.BuildId) propsJson.Set("assetPrefix", config.AssetPrefix) r.Response.WriteTpl(config.CacheBuildId+"/chat.html", g.Map{ @@ -117,7 +117,7 @@ func C(r *ghttp.Request) { propsJson := gjson.New(props) propsJson.Set("query.default.1", convId) - propsJson.Set("buildId", config.CacheBuildId) + propsJson.Set("buildId", config.BuildId) propsJson.Set("assetPrefix", config.AssetPrefix) r.Response.WriteTpl(config.CacheBuildId+"/chat.html", g.Map{ @@ -128,6 +128,59 @@ func C(r *ghttp.Request) { }) } +// Gpts +func Gpts(r *ghttp.Request) { + + if r.Session.MustGet("offical-session").IsEmpty() { + r.Session.RemoveAll() + r.Response.RedirectTo("/login") + return + } + props := ` + { + "props": { + "pageProps": { + "user": { + "id": "user-xyhelper", + "name": "admin@openai.com", + "email": "admin@openai.com", + "image": "/avatars.png", + "picture": "/avatars.png", + "idp": "auth0", + "iat": 2699699364, + "mfa": false, + "groups": [] + }, + "serviceStatus": {}, + "userCountry": "US", + "serviceAnnouncement": { "public": {}, "paid": {} }, + "serverPrimedAllowBrowserStorageValue": true, + "canManageBrowserStorage": false, + "ageVerificationDeadline": null, + "showCookieConsentBanner": false + }, + "__N_SSP": true + }, + "page": "/gpts", + "query": {}, + "buildId": "wtXFegAXt6bfbujLr1e7S", + "assetPrefix": "", + "isFallback": false, + "gssp": true, + "scriptLoader": [] + } + ` + propsJson := gjson.New(props) + propsJson.Set("buildId", config.BuildId) + + r.Response.WriteTpl(config.CacheBuildId+"/gpts.html", g.Map{ + "arkoseUrl": config.ArkoseUrl, + "props": propsJson, + "assetPrefix": config.AssetPrefix, + "envScript": config.GetEnvScript(r.GetCtx()), + }) +} + // Discovery 发现 func Discovery(r *ghttp.Request) { @@ -171,7 +224,7 @@ func Discovery(r *ghttp.Request) { } ` propsJson := gjson.New(props) - propsJson.Set("buildId", config.CacheBuildId) + propsJson.Set("buildId", config.BuildId) r.Response.WriteTpl(config.CacheBuildId+"/discovery.html", g.Map{ "arkoseUrl": config.ArkoseUrl, @@ -225,7 +278,7 @@ func Editor(r *ghttp.Request) { } ` propsJson := gjson.New(props) - propsJson.Set("buildId", config.CacheBuildId) + propsJson.Set("buildId", config.BuildId) propsJson.Set("assetPrefix", config.AssetPrefix) // if slug != "" { @@ -289,7 +342,7 @@ func Slug(r *ghttp.Request) { propsJson := gjson.New(props) propsJson.Set("query.slug", slug) - propsJson.Set("buildId", config.CacheBuildId) + propsJson.Set("buildId", config.BuildId) propsJson.Set("assetPrefix", config.AssetPrefix) r.Response.WriteTpl(config.CacheBuildId+"/slug.html", g.Map{ @@ -347,7 +400,7 @@ func G(r *ghttp.Request) { ` propsJson := gjson.New(props) propsJson.Set("query.gizmoId", gizmoId) - propsJson.Set("buildId", config.CacheBuildId) + propsJson.Set("buildId", config.BuildId) propsJson.Set("assetPrefix", config.AssetPrefix) r.Response.WriteTpl(config.CacheBuildId+"/g.html", g.Map{ @@ -409,7 +462,7 @@ func GC(r *ghttp.Request) { propsJson := gjson.New(props) propsJson.Set("query.gizmoId", gizmoId) propsJson.Set("query.convId", convId) - propsJson.Set("buildId", config.CacheBuildId) + propsJson.Set("buildId", config.BuildId) r.Response.WriteTpl(config.CacheBuildId+"/gc.html", g.Map{ "arkoseUrl": config.ArkoseUrl, @@ -464,7 +517,7 @@ func Mine(r *ghttp.Request) { "scriptLoader": [] }` propsJson := gjson.New(props) - propsJson.Set("buildId", config.CacheBuildId) + propsJson.Set("buildId", config.BuildId) propsJson.Set("assetPrefix", config.AssetPrefix) r.Response.WriteTpl(config.CacheBuildId+"/mine.html", g.Map{ diff --git a/backend-api/backend-api.go b/backend-api/backend-api.go index 6a6a2f6..339ebe1 100644 --- a/backend-api/backend-api.go +++ b/backend-api/backend-api.go @@ -38,28 +38,36 @@ func NotFound(r *ghttp.Request) { func ProxyAll(r *ghttp.Request) { ctx := r.GetCtx() // 获取header中的token Authorization: Bearer xxx 去掉Bearer + userToken := "" + Authorization := r.Header.Get("Authorization") + if Authorization != "" { + userToken = r.Header.Get("Authorization")[7:] + } + g.Log().Debug(ctx, "userToken", userToken) - userToken := r.Header.Get("Authorization")[7:] - officialAccessToken := AccessTokenCache.MustGet(ctx, userToken).String() - if officialAccessToken == "" { - record, _, err := ChatgptSessionService.GetSessionByUserToken(ctx, userToken) - if err != nil { - g.Log().Error(ctx, err) - r.Response.WriteStatus(http.StatusUnauthorized) - return - } - if record.IsEmpty() { - g.Log().Error(ctx, "session is empty") - r.Response.WriteStatus(http.StatusUnauthorized) - return + officialAccessToken := "" + if userToken != "" { + officialAccessToken = AccessTokenCache.MustGet(ctx, userToken).String() + if officialAccessToken == "" { + record, _, err := ChatgptSessionService.GetSessionByUserToken(ctx, userToken) + if err != nil { + g.Log().Error(ctx, err) + r.Response.WriteStatus(http.StatusUnauthorized) + return + } + if record.IsEmpty() { + g.Log().Error(ctx, "session is empty") + r.Response.WriteStatus(http.StatusUnauthorized) + return + } + officialSession := record["officialSession"].String() + if officialSession == "" { + r.Response.WriteStatus(http.StatusUnauthorized) + return + } + officialAccessToken = utility.AccessTokenFormSession(officialSession) + AccessTokenCache.Set(ctx, userToken, officialAccessToken, time.Minute) } - officialSession := record["officialSession"].String() - if officialSession == "" { - r.Response.WriteStatus(http.StatusUnauthorized) - return - } - officialAccessToken = utility.AccessTokenFormSession(officialSession) - AccessTokenCache.Set(ctx, userToken, officialAccessToken, time.Minute) } UpStream := config.CHATPROXY(ctx) u, _ := url.Parse(UpStream) @@ -73,7 +81,10 @@ func ProxyAll(r *ghttp.Request) { newreq.URL.Scheme = u.Scheme newreq.Host = u.Host newreq.Header.Set("authkey", config.AUTHKEY(ctx)) - newreq.Header.Set("Authorization", "Bearer "+officialAccessToken) + g.Log().Debug(ctx, "officialAccessToken", officialAccessToken) + if officialAccessToken != "" { + newreq.Header.Set("Authorization", "Bearer "+officialAccessToken) + } // g.Dump(newreq.URL) proxy.ServeHTTP(r.Response.Writer.RawWriter(), newreq) diff --git a/config.yaml b/config.yaml index 8b38cee..3aa67fd 100644 --- a/config.yaml +++ b/config.yaml @@ -56,8 +56,8 @@ modules: enable: 1 # 接入网关地址 -# CHATPROXY: "https://demo.xyhelper.cn" -CHATPROXY: "https://chatproxy-dev.closeai.biz" +CHATPROXY: "https://demo.xyhelper.cn" +# CHATPROXY: "https://chatproxy-dev.closeai.biz" # 接入网关的authkey AUTHKEY: "xyhelper" ONLYTOKEN: true diff --git a/main.go b/main.go index 73dc913..38621aa 100644 --- a/main.go +++ b/main.go @@ -10,6 +10,7 @@ import ( _ "chatgpt-mirror-server/api" _ "chatgpt-mirror-server/backend-api" _ "chatgpt-mirror-server/modules" + _ "chatgpt-mirror-server/public-api" "github.com/gogf/gf/v2/os/gctx" diff --git a/public-api/proxypublic.go b/public-api/proxypublic.go new file mode 100644 index 0000000..027888a --- /dev/null +++ b/public-api/proxypublic.go @@ -0,0 +1,29 @@ +package publicapi + +import ( + "chatgpt-mirror-server/config" + "net/http" + "net/http/httputil" + "net/url" + + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/net/ghttp" +) + +func ProxyPublic(r *ghttp.Request) { + ctx := r.GetCtx() + u, _ := url.Parse(config.CHATPROXY(ctx)) + proxy := httputil.NewSingleHostReverseProxy(u) + 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("Cookie", "__Secure-next-auth.session-token="+carinfo.RefreshCookie) + // // 去除header 中的 压缩 + // newreq.Header.Del("Accept-Encoding") + proxy.ServeHTTP(r.Response.Writer.RawWriter(), newreq) +} diff --git a/public-api/public-api.go b/public-api/public-api.go new file mode 100644 index 0000000..e47598b --- /dev/null +++ b/public-api/public-api.go @@ -0,0 +1,9 @@ +package publicapi + +import "github.com/gogf/gf/v2/frame/g" + +func init() { + s := g.Server() + publicApiGroup := s.Group("/public-api") + publicApiGroup.ALL("/*", ProxyPublic) +} diff --git a/resource/template/Rp5H7oULko6u7cJEjMucd/chat.html b/resource/template/Rp5H7oULko6u7cJEjMucd/chat.html new file mode 100644 index 0000000..22810c9 --- /dev/null +++ b/resource/template/Rp5H7oULko6u7cJEjMucd/chat.html @@ -0,0 +1 @@ +{{.envScript}}ChatGPT
\ No newline at end of file diff --git a/resource/template/Rp5H7oULko6u7cJEjMucd/discovery.html b/resource/template/Rp5H7oULko6u7cJEjMucd/discovery.html new file mode 100644 index 0000000..2041ac0 --- /dev/null +++ b/resource/template/Rp5H7oULko6u7cJEjMucd/discovery.html @@ -0,0 +1 @@ +{{.envScript}}ChatGPT
\ No newline at end of file diff --git a/resource/template/Rp5H7oULko6u7cJEjMucd/editor.html b/resource/template/Rp5H7oULko6u7cJEjMucd/editor.html new file mode 100644 index 0000000..d42e675 --- /dev/null +++ b/resource/template/Rp5H7oULko6u7cJEjMucd/editor.html @@ -0,0 +1 @@ +{{.envScript}}ChatGPT
\ No newline at end of file diff --git a/resource/template/Rp5H7oULko6u7cJEjMucd/g.html b/resource/template/Rp5H7oULko6u7cJEjMucd/g.html new file mode 100644 index 0000000..5a7eb42 --- /dev/null +++ b/resource/template/Rp5H7oULko6u7cJEjMucd/g.html @@ -0,0 +1 @@ +{{.envScript}}ChatGPT
\ No newline at end of file diff --git a/resource/template/Rp5H7oULko6u7cJEjMucd/gc.html b/resource/template/Rp5H7oULko6u7cJEjMucd/gc.html new file mode 100644 index 0000000..856a0a7 --- /dev/null +++ b/resource/template/Rp5H7oULko6u7cJEjMucd/gc.html @@ -0,0 +1 @@ +{{.envScript}}ChatGPT
\ No newline at end of file diff --git a/resource/template/Rp5H7oULko6u7cJEjMucd/gpts.html b/resource/template/Rp5H7oULko6u7cJEjMucd/gpts.html new file mode 100644 index 0000000..2041ac0 --- /dev/null +++ b/resource/template/Rp5H7oULko6u7cJEjMucd/gpts.html @@ -0,0 +1 @@ +{{.envScript}}ChatGPT
\ No newline at end of file diff --git a/resource/template/Rp5H7oULko6u7cJEjMucd/mine.html b/resource/template/Rp5H7oULko6u7cJEjMucd/mine.html new file mode 100644 index 0000000..b037c84 --- /dev/null +++ b/resource/template/Rp5H7oULko6u7cJEjMucd/mine.html @@ -0,0 +1 @@ +{{.envScript}}ChatGPT
\ No newline at end of file diff --git a/resource/template/Rp5H7oULko6u7cJEjMucd/slug.html b/resource/template/Rp5H7oULko6u7cJEjMucd/slug.html new file mode 100644 index 0000000..28b27f6 --- /dev/null +++ b/resource/template/Rp5H7oULko6u7cJEjMucd/slug.html @@ -0,0 +1 @@ +{{.envScript}}ChatGPT
\ No newline at end of file diff --git a/resource/template/WtU07IOQoMFgLEFUvpFfy/chat.html b/resource/template/WtU07IOQoMFgLEFUvpFfy/chat.html new file mode 100644 index 0000000..94f5d78 --- /dev/null +++ b/resource/template/WtU07IOQoMFgLEFUvpFfy/chat.html @@ -0,0 +1 @@ +{{.envScript}}ChatGPT
\ No newline at end of file diff --git a/resource/template/WtU07IOQoMFgLEFUvpFfy/discovery.html b/resource/template/WtU07IOQoMFgLEFUvpFfy/discovery.html new file mode 100644 index 0000000..2cbb12a --- /dev/null +++ b/resource/template/WtU07IOQoMFgLEFUvpFfy/discovery.html @@ -0,0 +1 @@ +{{.envScript}}ChatGPT
\ No newline at end of file diff --git a/resource/template/WtU07IOQoMFgLEFUvpFfy/editor.html b/resource/template/WtU07IOQoMFgLEFUvpFfy/editor.html new file mode 100644 index 0000000..0ad9a3b --- /dev/null +++ b/resource/template/WtU07IOQoMFgLEFUvpFfy/editor.html @@ -0,0 +1 @@ +{{.envScript}}ChatGPT
\ No newline at end of file diff --git a/resource/template/WtU07IOQoMFgLEFUvpFfy/g.html b/resource/template/WtU07IOQoMFgLEFUvpFfy/g.html new file mode 100644 index 0000000..adda6bc --- /dev/null +++ b/resource/template/WtU07IOQoMFgLEFUvpFfy/g.html @@ -0,0 +1 @@ +{{.envScript}}ChatGPT
\ No newline at end of file diff --git a/resource/template/WtU07IOQoMFgLEFUvpFfy/gc.html b/resource/template/WtU07IOQoMFgLEFUvpFfy/gc.html new file mode 100644 index 0000000..b63d997 --- /dev/null +++ b/resource/template/WtU07IOQoMFgLEFUvpFfy/gc.html @@ -0,0 +1 @@ +{{.envScript}}ChatGPT
\ No newline at end of file diff --git a/resource/template/WtU07IOQoMFgLEFUvpFfy/mine.html b/resource/template/WtU07IOQoMFgLEFUvpFfy/mine.html new file mode 100644 index 0000000..2702f15 --- /dev/null +++ b/resource/template/WtU07IOQoMFgLEFUvpFfy/mine.html @@ -0,0 +1 @@ +{{.envScript}}ChatGPT
\ No newline at end of file diff --git a/resource/template/WtU07IOQoMFgLEFUvpFfy/slug.html b/resource/template/WtU07IOQoMFgLEFUvpFfy/slug.html new file mode 100644 index 0000000..94e2859 --- /dev/null +++ b/resource/template/WtU07IOQoMFgLEFUvpFfy/slug.html @@ -0,0 +1 @@ +{{.envScript}}ChatGPT
\ No newline at end of file From 0d38e0bdd32662979943b8c196382b5a9310f345 Mon Sep 17 00:00:00 2001 From: abc Date: Sat, 13 Jan 2024 23:40:45 +0800 Subject: [PATCH 4/4] =?UTF-8?q?fix:=20=E9=80=82=E9=85=8D=E6=9C=80=E6=96=B0?= =?UTF-8?q?=E7=9A=84gps=E7=9A=84UI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend-api/backend-api.go | 2 +- backend-api/me.go | 1 + public-api/proxypublic.go | 2 ++ resource/template/v78GkVQvDccUOBvZi02mN/chat.html | 1 + resource/template/v78GkVQvDccUOBvZi02mN/discovery.html | 1 + resource/template/v78GkVQvDccUOBvZi02mN/editor.html | 1 + resource/template/v78GkVQvDccUOBvZi02mN/g.html | 1 + resource/template/v78GkVQvDccUOBvZi02mN/gc.html | 1 + resource/template/v78GkVQvDccUOBvZi02mN/gpts.html | 1 + resource/template/v78GkVQvDccUOBvZi02mN/mine.html | 1 + resource/template/v78GkVQvDccUOBvZi02mN/slug.html | 1 + 11 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 resource/template/v78GkVQvDccUOBvZi02mN/chat.html create mode 100644 resource/template/v78GkVQvDccUOBvZi02mN/discovery.html create mode 100644 resource/template/v78GkVQvDccUOBvZi02mN/editor.html create mode 100644 resource/template/v78GkVQvDccUOBvZi02mN/g.html create mode 100644 resource/template/v78GkVQvDccUOBvZi02mN/gc.html create mode 100644 resource/template/v78GkVQvDccUOBvZi02mN/gpts.html create mode 100644 resource/template/v78GkVQvDccUOBvZi02mN/mine.html create mode 100644 resource/template/v78GkVQvDccUOBvZi02mN/slug.html diff --git a/backend-api/backend-api.go b/backend-api/backend-api.go index 80c9243..0e9c443 100644 --- a/backend-api/backend-api.go +++ b/backend-api/backend-api.go @@ -28,7 +28,7 @@ var ( func init() { s := g.Server() s.BindHandler("/backend-api/*any", ProxyAll) - s.BindHandler("/public-api/*any", ProxyAll) + // s.BindHandler("/public-api/*any", ProxyAll) // s.BindHandler("/_next/data/*any", NextDataGptsFixed) backendGroup := s.Group("/backend-api") backendGroup.POST("/accounts/data_export", NotFound) // 禁用导出 diff --git a/backend-api/me.go b/backend-api/me.go index 7bb74c6..01a45cb 100644 --- a/backend-api/me.go +++ b/backend-api/me.go @@ -40,6 +40,7 @@ func Me(r *ghttp.Request) { res, err := g.Client().SetHeaderMap(map[string]string{ "Authorization": "Bearer " + AccessToken, "User-Agent": r.Header.Get("User-Agent"), + "authKey": config.AUTHKEY(ctx), }).Get(ctx, UpStream+"/backend-api/me") if err != nil { r.Response.WriteStatus(http.StatusUnauthorized) diff --git a/public-api/proxypublic.go b/public-api/proxypublic.go index 027888a..be50609 100644 --- a/public-api/proxypublic.go +++ b/public-api/proxypublic.go @@ -22,6 +22,8 @@ func ProxyPublic(r *ghttp.Request) { newreq.URL.Host = u.Host newreq.URL.Scheme = u.Scheme newreq.Host = u.Host + newreq.Header.Set("authkey", config.AUTHKEY(ctx)) + // newreq.Header.Set("Cookie", "__Secure-next-auth.session-token="+carinfo.RefreshCookie) // // 去除header 中的 压缩 // newreq.Header.Del("Accept-Encoding") diff --git a/resource/template/v78GkVQvDccUOBvZi02mN/chat.html b/resource/template/v78GkVQvDccUOBvZi02mN/chat.html new file mode 100644 index 0000000..da3fe55 --- /dev/null +++ b/resource/template/v78GkVQvDccUOBvZi02mN/chat.html @@ -0,0 +1 @@ +{{.envScript}}ChatGPT
\ No newline at end of file diff --git a/resource/template/v78GkVQvDccUOBvZi02mN/discovery.html b/resource/template/v78GkVQvDccUOBvZi02mN/discovery.html new file mode 100644 index 0000000..802d817 --- /dev/null +++ b/resource/template/v78GkVQvDccUOBvZi02mN/discovery.html @@ -0,0 +1 @@ +{{.envScript}}ChatGPT
\ No newline at end of file diff --git a/resource/template/v78GkVQvDccUOBvZi02mN/editor.html b/resource/template/v78GkVQvDccUOBvZi02mN/editor.html new file mode 100644 index 0000000..496c0fe --- /dev/null +++ b/resource/template/v78GkVQvDccUOBvZi02mN/editor.html @@ -0,0 +1 @@ +{{.envScript}}ChatGPT
\ No newline at end of file diff --git a/resource/template/v78GkVQvDccUOBvZi02mN/g.html b/resource/template/v78GkVQvDccUOBvZi02mN/g.html new file mode 100644 index 0000000..d1f3f8b --- /dev/null +++ b/resource/template/v78GkVQvDccUOBvZi02mN/g.html @@ -0,0 +1 @@ +{{.envScript}}ChatGPT
\ No newline at end of file diff --git a/resource/template/v78GkVQvDccUOBvZi02mN/gc.html b/resource/template/v78GkVQvDccUOBvZi02mN/gc.html new file mode 100644 index 0000000..1e46372 --- /dev/null +++ b/resource/template/v78GkVQvDccUOBvZi02mN/gc.html @@ -0,0 +1 @@ +{{.envScript}}ChatGPT
\ No newline at end of file diff --git a/resource/template/v78GkVQvDccUOBvZi02mN/gpts.html b/resource/template/v78GkVQvDccUOBvZi02mN/gpts.html new file mode 100644 index 0000000..802d817 --- /dev/null +++ b/resource/template/v78GkVQvDccUOBvZi02mN/gpts.html @@ -0,0 +1 @@ +{{.envScript}}ChatGPT
\ No newline at end of file diff --git a/resource/template/v78GkVQvDccUOBvZi02mN/mine.html b/resource/template/v78GkVQvDccUOBvZi02mN/mine.html new file mode 100644 index 0000000..fbbd273 --- /dev/null +++ b/resource/template/v78GkVQvDccUOBvZi02mN/mine.html @@ -0,0 +1 @@ +{{.envScript}}ChatGPT
\ No newline at end of file diff --git a/resource/template/v78GkVQvDccUOBvZi02mN/slug.html b/resource/template/v78GkVQvDccUOBvZi02mN/slug.html new file mode 100644 index 0000000..492ec11 --- /dev/null +++ b/resource/template/v78GkVQvDccUOBvZi02mN/slug.html @@ -0,0 +1 @@ +{{.envScript}}ChatGPT
\ No newline at end of file