mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-06-03 05:40:37 +08:00
Merge pull request #2834 from muzhi1991/fix/openai-compat-host-header
fix(util): forward custom Host header to upstream
This commit is contained in:
@@ -47,6 +47,14 @@ func applyCustomHeaders(r *http.Request, headers map[string]string) {
|
||||
if k == "" || v == "" {
|
||||
continue
|
||||
}
|
||||
// net/http reads Host from req.Host (not req.Header) when writing
|
||||
// a real request, so we must mirror it there. Some callers pass
|
||||
// synthetic requests (e.g. &http.Request{Header: ...}) and only
|
||||
// consume r.Header afterwards, so keep the value in the header
|
||||
// map too.
|
||||
if http.CanonicalHeaderKey(k) == "Host" {
|
||||
r.Host = v
|
||||
}
|
||||
r.Header.Set(k, v)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user