fix: proxy settings not applied when request MJ image url

This commit is contained in:
skynono
2025-05-16 17:45:17 +08:00
parent 7171a69512
commit 9927e5d191

View File

@@ -32,7 +32,23 @@ func RelayMidjourneyImage(c *gin.Context) {
}) })
return return
} }
resp, err := http.Get(midjourneyTask.ImageUrl) var httpClient *http.Client
if channel, err := model.CacheGetChannel(midjourneyTask.ChannelId); err == nil {
if proxy, ok := channel.GetSetting()["proxy"]; ok {
if proxyURL, ok := proxy.(string); ok && proxyURL != "" {
if httpClient, err = service.NewProxyHttpClient(proxyURL); err != nil {
c.JSON(400, gin.H{
"error": "proxy_url_invalid",
})
return
}
}
}
}
if httpClient == nil {
httpClient = service.GetHttpClient()
}
resp, err := httpClient.Get(midjourneyTask.ImageUrl)
if err != nil { if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{ c.JSON(http.StatusInternalServerError, gin.H{
"error": "http_get_image_failed", "error": "http_get_image_failed",