Skip to content

feat: set custom User-Agent header for API requests#196

Open
chingjustwe wants to merge 1 commit into
lessweb:mainfrom
chingjustwe:feature/deepcode-user-agent
Open

feat: set custom User-Agent header for API requests#196
chingjustwe wants to merge 1 commit into
lessweb:mainfrom
chingjustwe:feature/deepcode-user-agent

Conversation

@chingjustwe

Copy link
Copy Markdown

feat: set custom User-Agent header for API requests

Problem

When using deepcode-cli with custom/proxy API endpoints routed through Cloudflare or strict enterprise WAFs, requests fail with 403 Forbidden. The root cause is that the OpenAI SDK sends User-Agent: OpenAI/JS x.x.x by default, which proxy operators commonly block via WAF rules to prevent abuse of their OpenAI relay services.

Changes

  1. New src/common/package-info.ts — central place that reads package.json once and exports APP_NAME and APP_VERSION as shared constants.

  2. src/common/openai-client.ts — override the User-Agent in the custom fetch wrapper from OpenAI/JS 6.35.0 to deepcode-cli/${version} (e.g. deepcode-cli/0.1.27). This references the same pattern as opencode: opencode/${version}.

  3. src/cli.tsx — use the shared APP_NAME / APP_VERSION from package-info.ts instead of local require("../package.json").

Verification

  • deepcode --version outputs the correct version
  • All 410 tests pass
  • TypeScript typecheck, ESLint, Prettier all pass
  • Build (npm run build) succeeds

Related Issue

#177

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