Skip to content

Custom HTTP headers for proxy and faucet API requests#564

Merged
popenta merged 1 commit intomultiversx:http-headersfrom
BubuMVX:feat/proxy-headers
Apr 23, 2026
Merged

Custom HTTP headers for proxy and faucet API requests#564
popenta merged 1 commit intomultiversx:http-headersfrom
BubuMVX:feat/proxy-headers

Conversation

@BubuMVX
Copy link
Copy Markdown
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"

@popenta popenta changed the base branch from main to http-headers April 23, 2026 08:50
@popenta popenta merged commit e4f6204 into multiversx:http-headers Apr 23, 2026
3 checks passed
@popenta
Copy link
Copy Markdown
Collaborator

popenta commented Apr 23, 2026

Merged the PR in another branch just to allow the actions to run. We'll review the PR and then we'll merge it into main.

PR

@BubuMVX
Copy link
Copy Markdown
Contributor Author

BubuMVX commented Apr 23, 2026

Thanks @popenta !
To fix GitHub Actions on this repo, I suggested some changes in #565.
Feel free to cherry pick, update or reject them.

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.

2 participants