Add support for custom headers and migrate from legacy auth
- Introduced CustomHeaders component for managing custom headers. - Updated Sidebar to include CustomHeaders component. - Enhanced useConnection hook to handle custom headers and legacy auth migration. - Added tests for custom headers functionality. - Updated package.json and package-lock.json for new dependencies.
This commit is contained in:
parent
b476ece67e
commit
c5acc63129
1 changed files with 606 additions and 48 deletions
|
|
@ -90,6 +90,23 @@ const getHttpHeaders = (req: express.Request): Record<string, string> => {
|
|||
}
|
||||
}
|
||||
|
||||
// Handle multiple custom headers (new approach)
|
||||
if (req.headers["x-custom-auth-headers"] !== undefined) {
|
||||
try {
|
||||
const customHeaderNames = JSON.parse(req.headers["x-custom-auth-headers"] as string) as string[];
|
||||
if (Array.isArray(customHeaderNames)) {
|
||||
customHeaderNames.forEach((headerName) => {
|
||||
const lowerCaseHeaderName = headerName.toLowerCase();
|
||||
if (req.headers[lowerCaseHeaderName] !== undefined) {
|
||||
const value = req.headers[lowerCaseHeaderName];
|
||||
headers[headerName] = Array.isArray(value) ? value[value.length - 1] : value;
|
||||
}
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn("Failed to parse x-custom-auth-headers:", error);
|
||||
}
|
||||
}
|
||||
return headers;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue