feat: support custom authorization headers, fix #395

This commit is contained in:
xiaoli 2025-05-13 23:38:19 +08:00
commit 618f24a9ac

View file

@ -297,7 +297,12 @@ export function useConnection({
bearerToken || (await serverAuthProvider.tokens())?.access_token;
if (token) {
const authHeaderName = headerName || "Authorization";
headers[authHeaderName] = `Bearer ${token}`;
headers[authHeaderName] = token;
// Add custom header name as a special request header to let the server know which header to pass through
if (headerName && headerName.toLowerCase() !== "authorization") {
headers["x-custom-auth-header"] = headerName;
}
}
// Create appropriate transport