Skip to content

Commit

Permalink
修改转发openai web的host优先取设置的
Browse files Browse the repository at this point in the history
  • Loading branch information
zatxm committed May 23, 2024
1 parent 60d2495 commit 2c49429
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions internal/openai/api/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,18 @@ func DoWeb(tag string) func(*fhblade.Context) error {
"oai-language": {cst.OaiLanguage},
"user-agent": {vars.UserAgent},
}
urlHost := cst.ChatHost
webChatUrl := config.OpenaiChatWebUrl()
if webChatUrl != "" {
urlHost = strings.TrimPrefix(webChatUrl, "https://")
urlHost = strings.TrimPrefix(urlHost, "http://")
}
gClient := client.CPool.Get().(tlsClient.HttpClient)
defer client.CPool.Put(gClient)
goProxy := httputil.ReverseProxy{
Director: func(req *http.Request) {
req.Host = cst.ChatHost
req.URL.Host = cst.ChatHost
req.Host = urlHost
req.URL.Host = urlHost
req.URL.Scheme = "https"
req.URL.Path = path
req.URL.RawQuery = query
Expand Down

0 comments on commit 2c49429

Please sign in to comment.