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
42500b33
authored
Mar 05, 2026
by
feitianbubu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: fetch model add header passthrough rule key check
parent
5df8b34f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
0 deletions
+7
-0
controller/channel.go
+4
-0
relay/channel/api_request.go
+3
-0
No files found.
controller/channel.go
View file @
42500b33
...
@@ -13,6 +13,7 @@ import (
...
@@ -13,6 +13,7 @@ import (
"github.com/QuantumNous/new-api/constant"
"github.com/QuantumNous/new-api/constant"
"github.com/QuantumNous/new-api/dto"
"github.com/QuantumNous/new-api/dto"
"github.com/QuantumNous/new-api/model"
"github.com/QuantumNous/new-api/model"
relaychannel
"github.com/QuantumNous/new-api/relay/channel"
"github.com/QuantumNous/new-api/relay/channel/gemini"
"github.com/QuantumNous/new-api/relay/channel/gemini"
"github.com/QuantumNous/new-api/relay/channel/ollama"
"github.com/QuantumNous/new-api/relay/channel/ollama"
"github.com/QuantumNous/new-api/service"
"github.com/QuantumNous/new-api/service"
...
@@ -183,6 +184,9 @@ func buildFetchModelsHeaders(channel *model.Channel, key string) (http.Header, e
...
@@ -183,6 +184,9 @@ func buildFetchModelsHeaders(channel *model.Channel, key string) (http.Header, e
headerOverride
:=
channel
.
GetHeaderOverride
()
headerOverride
:=
channel
.
GetHeaderOverride
()
for
k
,
v
:=
range
headerOverride
{
for
k
,
v
:=
range
headerOverride
{
if
relaychannel
.
IsHeaderPassthroughRuleKey
(
k
)
{
continue
}
str
,
ok
:=
v
.
(
string
)
str
,
ok
:=
v
.
(
string
)
if
!
ok
{
if
!
ok
{
return
nil
,
fmt
.
Errorf
(
"invalid header override for key %s"
,
k
)
return
nil
,
fmt
.
Errorf
(
"invalid header override for key %s"
,
k
)
...
...
relay/channel/api_request.go
View file @
42500b33
...
@@ -100,6 +100,9 @@ func getHeaderPassthroughRegex(pattern string) (*regexp.Regexp, error) {
...
@@ -100,6 +100,9 @@ func getHeaderPassthroughRegex(pattern string) (*regexp.Regexp, error) {
return
compiled
,
nil
return
compiled
,
nil
}
}
func
IsHeaderPassthroughRuleKey
(
key
string
)
bool
{
return
isHeaderPassthroughRuleKey
(
key
)
}
func
isHeaderPassthroughRuleKey
(
key
string
)
bool
{
func
isHeaderPassthroughRuleKey
(
key
string
)
bool
{
key
=
strings
.
TrimSpace
(
key
)
key
=
strings
.
TrimSpace
(
key
)
if
key
==
""
{
if
key
==
""
{
...
...
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