feat: add custom headers support for sync providers#1960
feat: add custom headers support for sync providers#1960raflFaisal wants to merge 4 commits intoopen-feature:mainfrom
Conversation
✅ Deploy Preview for polite-licorice-3db33c ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
Code Review
This pull request introduces support for custom headers in both HTTP and gRPC sync providers, allowing users to specify key-value pairs via a new --sync-headers CLI flag or per-source configuration. The implementation includes logic to merge global and per-source headers, with per-source values taking precedence. Feedback focuses on ensuring deterministic behavior and correct precedence by handling header key case-insensitivity, specifically suggesting canonicalization of keys in the HTTP provider and using case-insensitive checks when merging global headers.
Add the ability to inject custom HTTP headers and gRPC metadata into outbound sync requests. Headers can be set globally via --sync-headers CLI flag or per-source in the JSON configuration. Per-source values take precedence over global values for conflicting keys. Signed-off-by: raflFaisal <faisal.rafi.mca@gmail.com>
bf0ad74 to
7914fca
Compare
f81e4aa to
7151e8f
Compare
Signed-off-by: raflFaisal <faisal.rafi.mca@gmail.com>
7151e8f to
ac9ce67
Compare
|
IMO it'd be simpler to drop the global The global + per-source merging adds complexity:
If someone has multiple sources needing the same headers, duplicating them in the source config is straightforward and explicit. WDYT? |
toddbaert
left a comment
There was a problem hiding this comment.
I'm in favor of this, but unless there's strong reason to, I'd prefer not to duplicate this as both a source option and a global option: #1960 (comment)
|
Thanks @toddbaert for the review. |
Signed-off-by: raflFaisal <faisal.rafi.mca@gmail.com>
43f7360 to
0655413
Compare
|



Summary
Add support for custom headers in HTTP and gRPC sync providers
Problem
flagd's sync providers cannot inject custom request headers into outbound requests. This limits integration with environments where intermediaries (API gateways, reverse proxies, service meshes) require specific headers for routing, tenant identification, or policy enforcement, resulting in errors like 421 Misdirected Request or misrouting.
Solution
flagd start --sources='[{"uri":"https://proxy-gateway.xyz.com/flags/sync","provider":"http","headers":{"X-Proxy-Gateway-Host":"backend-api.service"}}]'Headers are sent as HTTP request headers for HTTP sync and as gRPC metadata for gRPC sync.
Examples:
gRPC with headers:
Using environment variables:
Scope & compatibility
Fully backward compatible, headers are optional and default to empty
No behavior change for existing configurations
Covers both HTTP and gRPC sync providers
Test plan
Unit tests for HTTP sync header injection
Unit tests for gRPC sync metadata injection