@copilotkit/runtime
Version:
<img src="https://github.com/user-attachments/assets/0a6b64d9-e193-4940-a3f6-60334ac34084" alt="banner" style="border-radius: 12px; border: 2px solid #d6d4fa;" />
26 lines (24 loc) • 824 B
JavaScript
require("reflect-metadata");
//#region src/v2/runtime/handlers/header-utils.ts
/**
* Determines if a header should be forwarded based on the allowlist.
* Forwards: authorization header and all x-* custom headers.
*/
function shouldForwardHeader(headerName) {
const lower = headerName.toLowerCase();
return lower === "authorization" || lower.startsWith("x-");
}
/**
* Extracts headers that should be forwarded from a Request object.
* Forwards only authorization and x-* headers.
*/
function extractForwardableHeaders(request) {
const forwardableHeaders = {};
request.headers.forEach((value, key) => {
if (shouldForwardHeader(key)) forwardableHeaders[key] = value;
});
return forwardableHeaders;
}
//#endregion
exports.extractForwardableHeaders = extractForwardableHeaders;
//# sourceMappingURL=header-utils.cjs.map