Skip to content

Add HTTP/HTTPS proxy support via undici ProxyAgent - #1

Merged
rattalur merged 3 commits into
mainfrom
copilot/add-proxy-support-to-cli
Sep 3, 2026
Merged

Add HTTP/HTTPS proxy support via undici ProxyAgent#1
rattalur merged 3 commits into
mainfrom
copilot/add-proxy-support-to-cli

Conversation

Copilot AI commented Sep 3, 2026

Copy link
Copy Markdown

Node's built-in fetch (used by the generated API client) doesn't automatically honor HTTP_PROXY/HTTPS_PROXY/NO_PROXY, so the CLI was unable to reach app.codacy.com (or a custom CODACY_API_BASE_URL) from behind a corporate proxy on any Node version this CLI supports.

Proxy resolution helper

  • New src/utils/proxy.ts:
    • resolveProxyUrl(env) — resolves HTTPS_PROXY/HTTP_PROXY (case-insensitive; uppercase and HTTPS_PROXY take priority).
    • shouldBypassProxy(env, host) — honors NO_PROXY/no_proxy (exact match, .suffix match, *) against the Codacy API host.
    • configureProxyFromEnv(env) — installs an undici.ProxyAgent via setGlobalDispatcher when applicable; returns undefined (no-op) when no proxy is configured or it's bypassed.

Wiring

  • src/index.ts calls configureProxyFromEnv() before OpenAPI.BASE/OpenAPI.HEADERS are set and before any command is registered, so every subsequent fetch() routes through the proxy automatically.
  • Added undici as a direct dependency rather than relying on the transitive copy or Node 24's experimental NODE_USE_ENV_PROXY.

Docs & changeset

  • README.md: new "Proxy Support" section.
  • AGENTS.md: HTTPS_PROXY/HTTP_PROXY/NO_PROXY added to the Environment Variables table.
  • Minor changeset added.
HTTPS_PROXY=http://proxyhost:port codacy info

Copilot AI and others added 2 commits September 3, 2026 06:59
Co-authored-by: rattalur <145406381+rattalur@users.noreply.github.com>
Co-authored-by: rattalur <145406381+rattalur@users.noreply.github.com>
Copilot AI changed the title [WIP] Add first-class proxy support to Codacy CLI Add HTTP/HTTPS proxy support via undici ProxyAgent Sep 3, 2026
Copilot AI requested a review from rattalur September 3, 2026 07:04
@rattalur
rattalur marked this pull request as ready for review September 3, 2026 07:05
@rattalur
rattalur merged commit 625b8bc into main Sep 3, 2026
@rattalur
rattalur deleted the copilot/add-proxy-support-to-cli branch September 3, 2026 08:00
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