Title: Fix 403 Forbidden: Add User-Agent header to OpenAI client fetch to prevent WAF/Cloudflare blocks · Issue #177 · lessweb/deepcode-cli · GitHub
Open Graph Title: Fix 403 Forbidden: Add User-Agent header to OpenAI client fetch to prevent WAF/Cloudflare blocks · Issue #177 · lessweb/deepcode-cli
X Title: Fix 403 Forbidden: Add User-Agent header to OpenAI client fetch to prevent WAF/Cloudflare blocks · Issue #177 · lessweb/deepcode-cli
Description: Description When using deepcode-cli with custom/proxy API endpoints (e.g., endpoints routed through Cloudflare or strict enterprise WAFs), requests immediately fail with a 403 Your request was blocked error. Root Cause In the initializat...
Open Graph Description: Description When using deepcode-cli with custom/proxy API endpoints (e.g., endpoints routed through Cloudflare or strict enterprise WAFs), requests immediately fail with a 403 Your request was bloc...
X Description: Description When using deepcode-cli with custom/proxy API endpoints (e.g., endpoints routed through Cloudflare or strict enterprise WAFs), requests immediately fail with a 403 Your request was bloc...
Opengraph URL: https://github.com/lessweb/deepcode-cli/issues/177
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Fix 403 Forbidden: Add User-Agent header to OpenAI client fetch to prevent WAF/Cloudflare blocks","articleBody":"### Description\nWhen using `deepcode-cli` with custom/proxy API endpoints (e.g., endpoints routed through Cloudflare or strict enterprise WAFs), requests immediately fail with a `403 Your request was blocked` error.\n\n### Root Cause\nIn the initialization of the OpenAI client, the custom `fetch` implementation using `undiciFetch` does not provide a default `User-Agent`. \nMany CDNs and WAFs (like Cloudflare) automatically block HTTP requests missing a `User-Agent` as a basic anti-bot measure.\n\n`\typescript\n// Current implementation\nfetch: (url, init) =\u003e undiciFetch(url, { ...init, dispatcher: keepAliveAgent })\n`\n\n### Proposed Solution\nInject a standard or tool-specific `User-Agent` into the headers before passing them to `undiciFetch`. \n\n`\typescript\nfetch: (url, init) =\u003e {\n const headers = new Headers(init?.headers);\n if (!headers.has(\"User-Agent\")) {\n headers.set(\"User-Agent\", \"deepcode-cli/0.1.x (Node.js)\");\n }\n \n // Note: undiciFetch expects a plain object or an array of arrays for headers in some older TS setups, \n // so converting Headers back to an object might be necessary depending on the exact undici version used.\n const headersObj = Object.fromEntries(headers.entries());\n\n return undiciFetch(url, { \n ...init, \n headers: headersObj,\n dispatcher: keepAliveAgent \n });\n}\n`\n\n### Steps to Reproduce\n1. Set `BASE_URL` in `~/.deepcode/settings.json` to an API endpoint protected by Cloudflare.\n2. Run `deepcode` and send a message.\n3. Observe the `403 Your request was blocked` error.","author":{"url":"https://github.com/ID-VerNe","@type":"Person","name":"ID-VerNe"},"datePublished":"2026-06-14T02:34:54.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/177/deepcode-cli/issues/177"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:9d9a5fa2-0470-7024-7a1d-d5ef442d789b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9D26:179658:12B3890:1B4B269:6A4E41D7 |
| html-safe-nonce | 909e2577bafd33d28ffcef07dc328d88bc8e2d3e327b7ba231432b210c2cd4a9 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5RDI2OjE3OTY1ODoxMkIzODkwOjFCNEIyNjk6NkE0RTQxRDciLCJ2aXNpdG9yX2lkIjoiNDE5ODc3MzY4ODM0OTExNDgzOSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 576e7a07606ffc8a47072363353199807997847d56dd1aa05ddbd1ddb7d7f5fe |
| hovercard-subject-tag | issue:4657681083 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/lessweb/deepcode-cli/177/issue_layout |
| twitter:image | https://opengraph.githubassets.com/38ead7956d861679bc67c0910092e4c7536e5ec52f2c7cf4d3eae71ab2fdd4c2/lessweb/deepcode-cli/issues/177 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/38ead7956d861679bc67c0910092e4c7536e5ec52f2c7cf4d3eae71ab2fdd4c2/lessweb/deepcode-cli/issues/177 |
| og:image:alt | Description When using deepcode-cli with custom/proxy API endpoints (e.g., endpoints routed through Cloudflare or strict enterprise WAFs), requests immediately fail with a 403 Your request was bloc... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ID-VerNe |
| hostname | github.com |
| expected-hostname | github.com |
| None | 030096ee0db095447bfe77409d33bfac127ca7128299c58deef27c52eaa1b1f0 |
| turbo-cache-control | no-preview |
| go-import | github.com/lessweb/deepcode-cli git https://github.com/lessweb/deepcode-cli.git |
| octolytics-dimension-user_id | 118287711 |
| octolytics-dimension-user_login | lessweb |
| octolytics-dimension-repository_id | 1223512305 |
| octolytics-dimension-repository_nwo | lessweb/deepcode-cli |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1223512305 |
| octolytics-dimension-repository_network_root_nwo | lessweb/deepcode-cli |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 9fabff9b8b127e686a3ec86f91422e818056ca2c |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width