fix: preserve capitalization in custom headers

Express converts all header names to lowercase, which prevents custom headers with uppercase characters from being properly passed to the target service. This fix ensures that custom headers preserve their original capitalization when forwarded through the proxy.
This commit is contained in:
xiaoli 2025-05-30 14:43:09 +08:00
commit 3510e1a561

View file

@ -70,8 +70,9 @@ const getHttpHeaders = (
// If the header "x-custom-auth-header" is present, use its value as the custom header name. // If the header "x-custom-auth-header" is present, use its value as the custom header name.
if (req.headers["x-custom-auth-header"] !== undefined) { if (req.headers["x-custom-auth-header"] !== undefined) {
const customHeaderName = req.headers["x-custom-auth-header"] as string; const customHeaderName = req.headers["x-custom-auth-header"] as string;
if (req.headers[customHeaderName] !== undefined) { const lowerCaseHeaderName = customHeaderName.toLowerCase();
const value = req.headers[customHeaderName]; if (req.headers[lowerCaseHeaderName] !== undefined) {
const value = req.headers[lowerCaseHeaderName];
headers[customHeaderName] = value as string; headers[customHeaderName] = value as string;
} }
} }