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:
jeetul.samaiya 2025-08-26 18:51:06 +05:30
commit c5acc63129

View file

@ -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;
};