feat: support extra HTTP headers on API requests#205
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughAdds a new ChangesExtra HTTP Headers Support
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/cli.ts (1)
187-187: 💤 Low value
extraHeadersnot configurable via.tolgeerc.Unlike
API_KEY_OPT,PROJECT_ID_OPT, etc.,EXTRA_HEADERSis registered without.default(config.extraHeaders), so it can only be set via the flag orTOLGEE_EXTRA_HEADERS. If config-file support is desired for parity, wire a default (and extend theSchema); otherwise this is fine as-is.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/cli.ts` at line 187, The EXTRA_HEADERS option is added via program.addOption(EXTRA_HEADERS) but not wired to the loaded .tolgeerc config; call EXTRA_HEADERS.default(config.extraHeaders) before program.addOption to use the config value as the option default, and update the CLI configuration Schema to include an extraHeaders field so the config parser accepts it (adjust any types/validation in the Schema to match EXTRA_HEADERS' expected format). Ensure this change references the EXTRA_HEADERS constant and the config/Schema used when loading .tolgeerc in the same module.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/client/ApiClient.ts`:
- Around line 72-76: The headers object in ApiClient currently spreads
extraHeaders after USER_AGENT and apiKey, allowing callers to override protected
headers; update the headers creation in ApiClient (the object using USER_AGENT,
apiKey, and extraHeaders) to spread extraHeaders first (i.e., ...extraHeaders,
then 'user-agent': USER_AGENT and 'x-api-key': apiKey) so the CLI-managed
USER_AGENT and x-api-key remain authoritative and cannot be clobbered by
user-supplied headers.
---
Nitpick comments:
In `@src/cli.ts`:
- Line 187: The EXTRA_HEADERS option is added via
program.addOption(EXTRA_HEADERS) but not wired to the loaded .tolgeerc config;
call EXTRA_HEADERS.default(config.extraHeaders) before program.addOption to use
the config value as the option default, and update the CLI configuration Schema
to include an extraHeaders field so the config parser accepts it (adjust any
types/validation in the Schema to match EXTRA_HEADERS' expected format). Ensure
this change references the EXTRA_HEADERS constant and the config/Schema used
when loading .tolgeerc in the same module.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: cee9ee57-7eb4-4a78-8744-48ee14948fde
📒 Files selected for processing (5)
src/cli.tssrc/client/ApiClient.tssrc/options.tssrc/utils/extraHeaders.tstest/unit/extraHeaders.test.ts
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Adds a
--extra-headersoption (andTOLGEE_EXTRA_HEADERSenv var) to send extra HTTP headers with every Tolgee API request.Useful for self-hosted instances behind a gateway (Cloudflare Access, WAF, reverse proxy) that requires auth headers.
Headers are comma-separated
Name=Valuepairs:tolgee --extra-headers 'X-Foo=bar,X-Baz=qux' pullAdded unit tests for the parser. eslint, type check, and unit tests pass.
Closes #180
Summary by CodeRabbit
New Features
Tests