forked from feixuei/chatgpt-mirror-server
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:liuhuapiaoyuan/chatgpt-mirror-server
- Loading branch information
Showing
24 changed files
with
133 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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": "[email protected]", | ||
"email": "[email protected]", | ||
"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{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
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("authkey", config.AUTHKEY(ctx)) | ||
|
||
// newreq.Header.Set("Cookie", "__Secure-next-auth.session-token="+carinfo.RefreshCookie) | ||
// // 去除header 中的 压缩 | ||
// newreq.Header.Del("Accept-Encoding") | ||
proxy.ServeHTTP(r.Response.Writer.RawWriter(), newreq) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<!DOCTYPE html><html><head>{{.envScript}}<meta charSet="utf-8" /><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 name="viewport" content="width=device-width, initial-scale=1" /><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/36edb078e559dff3.css" as="style" /><link rel="stylesheet" href="{{.assetPrefix}}/_next/static/css/36edb078e559dff3.css" data-n-g /><noscript data-n-css></noscript><script defer nomodule src="{{.assetPrefix}}/_next/static/chunks/polyfills-c67a75d1b6f99dc8.js"></script><script src="{{.assetPrefix}}/_next/static/chunks/webpack-dcda336ac9faabba.js" defer></script><script src="{{.assetPrefix}}/_next/static/chunks/framework-31ffa51d236da229.js" defer></script><script src="{{.assetPrefix}}/_next/static/chunks/main-abb0536823058f9d.js" defer></script><script src="{{.assetPrefix}}/_next/static/chunks/pages/_app-81907334446d37b6.js" defer></script><script src="{{.assetPrefix}}/_next/static/chunks/pages/%5B%5B...default%5D%5D-12836b0c1baa69d7.js" defer></script><script src="{{.assetPrefix}}/_next/static/Rp5H7oULko6u7cJEjMucd/_buildManifest.js" defer></script><script src="{{.assetPrefix}}/_next/static/Rp5H7oULko6u7cJEjMucd/_ssgManifest.js" defer></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></div><script id="__NEXT_DATA__" type="application/json">{{.props}}</script><script></script></body></html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<!DOCTYPE html><html><head>{{.envScript}}<meta charSet="utf-8" /><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 name="viewport" content="width=device-width, initial-scale=1" /><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/36edb078e559dff3.css" as="style" /><link rel="stylesheet" href="{{.assetPrefix}}/_next/static/css/36edb078e559dff3.css" data-n-g /><noscript data-n-css></noscript><script defer nomodule src="{{.assetPrefix}}/_next/static/chunks/polyfills-c67a75d1b6f99dc8.js"></script><script src="{{.assetPrefix}}/_next/static/chunks/webpack-dcda336ac9faabba.js" defer></script><script src="{{.assetPrefix}}/_next/static/chunks/framework-31ffa51d236da229.js" defer></script><script src="{{.assetPrefix}}/_next/static/chunks/main-abb0536823058f9d.js" defer></script><script src="{{.assetPrefix}}/_next/static/chunks/pages/_app-81907334446d37b6.js" defer></script><script src="{{.assetPrefix}}/_next/static/chunks/6276-788aa034bc74dd94.js" defer></script><script src="{{.assetPrefix}}/_next/static/chunks/pages/gpts-feac991ac32a51df.js" defer></script><script src="{{.assetPrefix}}/_next/static/Rp5H7oULko6u7cJEjMucd/_buildManifest.js" defer></script><script src="{{.assetPrefix}}/_next/static/Rp5H7oULko6u7cJEjMucd/_ssgManifest.js" defer></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></div><script id="__NEXT_DATA__" type="application/json">{{.props}}</script><script></script></body></html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<!DOCTYPE html><html><head>{{.envScript}}<meta charSet="utf-8" /><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 name="viewport" content="width=device-width, initial-scale=1" /><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/36edb078e559dff3.css" as="style" /><link rel="stylesheet" href="{{.assetPrefix}}/_next/static/css/36edb078e559dff3.css" data-n-g /><noscript data-n-css></noscript><script defer nomodule src="{{.assetPrefix}}/_next/static/chunks/polyfills-c67a75d1b6f99dc8.js"></script><script src="{{.assetPrefix}}/_next/static/chunks/webpack-dcda336ac9faabba.js" defer></script><script src="{{.assetPrefix}}/_next/static/chunks/framework-31ffa51d236da229.js" defer></script><script src="{{.assetPrefix}}/_next/static/chunks/main-abb0536823058f9d.js" defer></script><script src="{{.assetPrefix}}/_next/static/chunks/pages/_app-81907334446d37b6.js" defer></script><script src="{{.assetPrefix}}/_next/static/chunks/192-63297905761f4832.js" defer></script><script src="{{.assetPrefix}}/_next/static/chunks/pages/gpts/editor-072951efa1e8a25c.js" defer></script><script src="{{.assetPrefix}}/_next/static/Rp5H7oULko6u7cJEjMucd/_buildManifest.js" defer></script><script src="{{.assetPrefix}}/_next/static/Rp5H7oULko6u7cJEjMucd/_ssgManifest.js" defer></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></div><script id="__NEXT_DATA__" type="application/json">{{.props}}</script><script></script></body></html> |
Oops, something went wrong.