Skip to content

Custom HTTP headers for proxy and faucet API requests#564

Open
BubuMVX wants to merge 1 commit intomultiversx:mainfrom
BubuMVX:feat/proxy-headers
Open

Custom HTTP headers for proxy and faucet API requests#564
BubuMVX wants to merge 1 commit intomultiversx:mainfrom
BubuMVX:feat/proxy-headers

Conversation

@BubuMVX
Copy link
Contributor

@BubuMVX BubuMVX commented Mar 21, 2026

Description

Summary

This change lets users attach extra HTTP headers to proxy traffic (MultiversX API / ProxyNetworkProvider) and to faucet native-auth API calls. That supports authenticated or gated gateways (for example API keys) without changing proxy URLs.

What changed

  • --proxy-headers KEY=VALUE [KEY=VALUE ...]: Added wherever add_proxy_arg() is used. Values are parsed in parse_proxy_headers(); each token must contain = or the CLI raises a clear error.
  • Global application: Before the subcommand runs, cli.py calls config.set_proxy_headers(...). get_config_for_network_providers() passes those headers to the SDK via NetworkProviderConfig(requests_options={"headers": ...}), so SDK proxy clients pick them up consistently.
  • mxpy faucet request: New --api-headers with the same KEY=VALUE form, forwarded to NativeAuthClientConfig(extra_request_headers=...).
  • Environment model: env.mxpy.json defaults and MxpyEnv include a proxy_headers field (documented as space-separated KEY=VALUE pairs in get_proxy_headers()).
  • utils.parse_headers_list(): Shared parsing for KEY=VALUE lists.
  • cli_get: Uses shared add_proxy_arg() so get subcommands get --proxy-headers like the rest of the CLI.
  • cli_tokens: TokenManagementController now builds ProxyNetworkProvider with get_config_for_network_providers() so token flows respect the same header configuration.
  • Tests: test_proxy_extra_headers asserts custom headers are passed through on ProxyNetworkProvider GETs (mocked requests.Session.get).
  • Docs: CLI.md updated with the new flags across affected commands.

Usage examples

mxpy get network-config \
  --proxy https://gateway.example.com \
  --proxy-headers "Api-Key=secret"
mxpy faucet request \
  --chain D \
  --api https://api.example.com \
  --api-headers "Api-Key=secret"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant