mirror of
https://github.com/lukaszraczylo/traefik-llmgateway.git
synced 2026-11-26 10:06:31 +00:00
fix(providers): do not follow upstream redirects
The adapter client re-sent provider API key headers to any redirect target. The client now returns the 3xx response to the caller. A test pins this behaviour.
This commit is contained in:
+8
-1
@@ -231,7 +231,14 @@ func newAdapterHTTPClient(timeout time.Duration) *http.Client {
|
||||
}
|
||||
tr.MaxIdleConnsPerHost = adapterIdleConnsPerHost
|
||||
tr.ResponseHeaderTimeout = timeout
|
||||
return &http.Client{Transport: tr}
|
||||
// Redirects are not followed: the client re-sends provider API key
|
||||
// headers, and a hijacked redirect target would receive them.
|
||||
return &http.Client{
|
||||
Transport: tr,
|
||||
CheckRedirect: func(*http.Request, []*http.Request) error {
|
||||
return http.ErrUseLastResponse
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// attemptRecorder is invoked once per upstream HTTP attempt a shared
|
||||
|
||||
Reference in New Issue
Block a user