Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
e5a141c3
authored
Nov 28, 2023
by
CaIon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix mj submit bug
parent
6e1f9cf6
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
4 additions
and
4 deletions
+4
-4
controller/relay-mj.go
+1
-1
controller/relay.go
+1
-1
middleware/auth.go
+2
-2
No files found.
controller/relay-mj.go
View file @
e5a141c3
...
@@ -327,7 +327,7 @@ func relayMidjourneySubmit(c *gin.Context, relayMode int) *MidjourneyResponse {
...
@@ -327,7 +327,7 @@ func relayMidjourneySubmit(c *gin.Context, relayMode int) *MidjourneyResponse {
//if c.Request.Header.Get("Authorization") != "" {
//if c.Request.Header.Get("Authorization") != "" {
// mjToken = strings.Split(c.Request.Header.Get("Authorization"), " ")[1]
// mjToken = strings.Split(c.Request.Header.Get("Authorization"), " ")[1]
//}
//}
req
.
Header
.
Set
(
"Authorization"
,
"Bearer midjourney-proxy"
)
//
req.Header.Set("Authorization", "Bearer midjourney-proxy")
req
.
Header
.
Set
(
"mj-api-secret"
,
strings
.
Split
(
c
.
Request
.
Header
.
Get
(
"Authorization"
),
" "
)[
1
])
req
.
Header
.
Set
(
"mj-api-secret"
,
strings
.
Split
(
c
.
Request
.
Header
.
Get
(
"Authorization"
),
" "
)[
1
])
// print request header
// print request header
log
.
Printf
(
"request header: %s"
,
req
.
Header
)
log
.
Printf
(
"request header: %s"
,
req
.
Header
)
...
...
controller/relay.go
View file @
e5a141c3
...
@@ -315,7 +315,7 @@ func RelayMidjourney(c *gin.Context) {
...
@@ -315,7 +315,7 @@ func RelayMidjourney(c *gin.Context) {
err
.
Result
=
"当前分组负载已饱和,请稍后再试,或升级账户以提升服务质量。"
err
.
Result
=
"当前分组负载已饱和,请稍后再试,或升级账户以提升服务质量。"
}
}
c
.
JSON
(
400
,
gin
.
H
{
c
.
JSON
(
400
,
gin
.
H
{
"error"
:
err
.
Result
,
"error"
:
err
.
Description
+
" "
+
err
.
Result
,
})
})
}
}
channelId
:=
c
.
GetInt
(
"channel_id"
)
channelId
:=
c
.
GetInt
(
"channel_id"
)
...
...
middleware/auth.go
View file @
e5a141c3
...
@@ -86,14 +86,14 @@ func TokenAuth() func(c *gin.Context) {
...
@@ -86,14 +86,14 @@ func TokenAuth() func(c *gin.Context) {
return
func
(
c
*
gin
.
Context
)
{
return
func
(
c
*
gin
.
Context
)
{
key
:=
c
.
Request
.
Header
.
Get
(
"Authorization"
)
key
:=
c
.
Request
.
Header
.
Get
(
"Authorization"
)
parts
:=
make
([]
string
,
0
)
parts
:=
make
([]
string
,
0
)
if
key
==
""
{
key
=
strings
.
TrimPrefix
(
key
,
"Bearer "
)
if
key
==
""
||
key
==
"midjourney-proxy"
{
key
=
c
.
Request
.
Header
.
Get
(
"mj-api-secret"
)
key
=
c
.
Request
.
Header
.
Get
(
"mj-api-secret"
)
key
=
strings
.
TrimPrefix
(
key
,
"Bearer "
)
key
=
strings
.
TrimPrefix
(
key
,
"Bearer "
)
key
=
strings
.
TrimPrefix
(
key
,
"sk-"
)
key
=
strings
.
TrimPrefix
(
key
,
"sk-"
)
parts
:=
strings
.
Split
(
key
,
"-"
)
parts
:=
strings
.
Split
(
key
,
"-"
)
key
=
parts
[
0
]
key
=
parts
[
0
]
}
else
{
}
else
{
key
=
strings
.
TrimPrefix
(
key
,
"Bearer "
)
key
=
strings
.
TrimPrefix
(
key
,
"sk-"
)
key
=
strings
.
TrimPrefix
(
key
,
"sk-"
)
parts
:=
strings
.
Split
(
key
,
"-"
)
parts
:=
strings
.
Split
(
key
,
"-"
)
key
=
parts
[
0
]
key
=
parts
[
0
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment