mirror of
https://github.com/linux-do/new-api.git
synced 2025-09-18 00:16:37 +08:00
fix: fix mj panic
This commit is contained in:
parent
222a55387d
commit
9b64f4a34a
@ -185,7 +185,12 @@ func DoMidjourneyHttpRequest(c *gin.Context, timeout time.Duration, fullRequestU
|
|||||||
req = req.WithContext(ctx)
|
req = req.WithContext(ctx)
|
||||||
req.Header.Set("Content-Type", c.Request.Header.Get("Content-Type"))
|
req.Header.Set("Content-Type", c.Request.Header.Get("Content-Type"))
|
||||||
req.Header.Set("Accept", c.Request.Header.Get("Accept"))
|
req.Header.Set("Accept", c.Request.Header.Get("Accept"))
|
||||||
req.Header.Set("mj-api-secret", strings.Split(c.Request.Header.Get("Authorization"), " ")[1])
|
auth := c.Request.Header.Get("Authorization")
|
||||||
|
if auth != "" {
|
||||||
|
auth = strings.TrimPrefix(auth, "Bearer ")
|
||||||
|
auth = strings.Split(auth, "-")[0]
|
||||||
|
req.Header.Set("mj-api-secret", auth)
|
||||||
|
}
|
||||||
defer cancel()
|
defer cancel()
|
||||||
resp, err := GetHttpClient().Do(req)
|
resp, err := GetHttpClient().Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user