This document outlines the Callora Backend proxy's header forwarding policy to ensure security and proper request routing while preventing sensitive information leakage.
The following headers are never forwarded to upstream services for security and privacy reasons:
x-api-key- API authentication keyauthorization- Bearer tokens and other authorization schemesproxy-authorization- Proxy authentication credentialscookie- HTTP cookies containing session data
host- The original request hostx-forwarded-for- Client IP address chainx-real-ip- Original client IP addressconnection- Connection control directiveskeep-alive- Persistent connection directivestransfer-encoding- Transfer encoding specificationste- Transfer encoding (legacy)trailer- Trailer header fieldsupgrade- Protocol upgrade directivesproxy-connection- Proxy connection directives
The proxy adds the following headers to all upstream requests:
x-request-id- Unique UUID v4 identifier for request tracing and correlation
All other headers not in the strip list are forwarded to upstream services, including but not limited to:
content-type- Media type of the request bodycontent-length- Length of the request bodyaccept- Preferred response media typesuser-agent- Client software identificationaccept-encoding- Preferred content encodingsaccept-language- Preferred response languages- Custom application headers (e.g.,
x-custom-*)
All upstream response headers are forwarded to the client except hop-by-hop headers:
connectionkeep-alivetransfer-encodingtetrailerupgrade
x-request-id- Always set to the proxy's request ID for correlation
Header stripping is performed case-insensitively. All header name variations (e.g., X-API-Key, x-api-key, X-API-KEY) are treated identically.
- API keys and authentication tokens are stripped to prevent credential leakage
- Network infrastructure headers are stripped to prevent IP address exposure
- Cookie headers are stripped to prevent session hijacking
- Unique
x-request-idheaders enable end-to-end request tracing - Request IDs are included in error responses for debugging
- UUID v4 format ensures global uniqueness
The header policy is implemented in src/routes/proxyRoutes.ts:
const DEFAULT_STRIP_HEADERS = [
'host',
'x-api-key',
'connection',
'keep-alive',
'transfer-encoding',
'te',
'trailer',
'upgrade',
'proxy-authorization',
'proxy-connection',
];Headers are processed case-insensitively using lowercase comparison:
const stripSet = new Set(config.stripHeaders.map((h) => h.toLowerCase()));
for (const [key, value] of Object.entries(req.headers)) {
if (!stripSet.has(key.toLowerCase()) && typeof value === 'string') {
forwardHeaders[key] = value;
}
}Comprehensive tests verify:
- Sensitive headers are stripped from upstream requests
- Safe headers are forwarded correctly
- Case-insensitive header stripping works
- Response headers are filtered appropriately
- Request ID correlation is maintained
See src/__tests__/proxy.integration.test.ts for detailed test coverage.