Skip to content

feat: support HTTPS targets and Anthropic /v1/messages format - #1

Open
SamirSaidani wants to merge 2 commits into
co-l:mainfrom
SamirSaidani:feat/https-anthropic-support
Open

feat: support HTTPS targets and Anthropic /v1/messages format#1
SamirSaidani wants to merge 2 commits into
co-l:mainfrom
SamirSaidani:feat/https-anthropic-support

Conversation

@SamirSaidani

Copy link
Copy Markdown

Summary

  • Add targetScheme: 'http' | 'https' config field (env: TARGET_SCHEME), persisted in proxy-config.json with 'http' fallback for backward compatibility
  • Route outbound proxy requests through https.request when scheme is https; fix Host header to match target (was leaking localhost:PORT, breaking Cloudflare/SNI routing)
  • Strip query string from stored request path to avoid hash grid breakage from params like ?beta=true; extend SQL filters to LIKE patterns for backward compat with existing DBs
  • Parse Anthropic /v1/messages format: normalise system field (string or content-block array), map thinking.budget_tokens to reasoningEffort, use startsWith for all path matching
  • Set NODE_EXTRA_CA_CERTS in start scripts for system CA trust; use rejectUnauthorized: false on outbound HTTPS agent (local dev tool)
  • Frontend: http/https <select> in config edit form; display scheme://host:port in header

Also proposes adding an explicit MIT license, consistent with the openfox project.

Usage with Anthropic / Claude Code

# Start Cache Hunter targeting Anthropic
TARGET_HOST=api.anthropic.com TARGET_PORT=443 TARGET_SCHEME=https WEB_PORT=4001 npm start

# Point Claude Code through the proxy
ANTHROPIC_BASE_URL=http://localhost:8787 claude

Test plan

  • npm run test:run — 128 tests passing
  • npx tsc --noEmit — 0 TypeScript errors
  • Proxy traffic from Claude Code CLI through Cache Hunter to api.anthropic.com
  • Sessions with /v1/messages requests display correctly in hash grid UI
  • Existing HTTP (vLLM) sessions unaffected

Enables Cache Hunter to proxy and capture traffic to remote HTTPS
endpoints such as api.anthropic.com, in addition to local HTTP targets.

- Add `targetScheme: 'http' | 'https'` to ProxyEngineConfig and
  StoredProxyConfig; persisted in proxy-config.json with http fallback
  for backward compatibility
- Route outbound proxy requests through https.request when scheme is
  https; fix Host header to match target (was leaking localhost:PORT)
- Strip query string from stored request path so hash grid path
  matching is not broken by params like ?beta=true
- Add TARGET_SCHEME env var; NODE_EXTRA_CA_CERTS set in start scripts
  for system CA trust; rejectUnauthorized:false on outbound HTTPS agent
  (local dev tool, user controls the proxy)
- Parse Anthropic /v1/messages format in parseRequestBody: normalise
  system field (string or content-block array), map thinking.budget_tokens
  to reasoningEffort, use startsWith for all path matching
- Extend SQL filters to LIKE patterns for backward compat with DBs that
  stored paths with query strings
- Frontend: add http/https <select> in config edit form; display full
  scheme://host:port in header
- 128 tests passing, 0 TypeScript errors
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