turborepo
379c5878 - fix(turbo-utils): Add proxy support to fetch requests (#11389)

Commit
46 days ago
fix(turbo-utils): Add proxy support to fetch requests (#11389) ## Summary Adds HTTP/HTTPS proxy support to `@turbo/utils` fetch requests using `undici`'s `ProxyAgent`. ## Problem After #11297, `create-turbo` switched from using `got` (which respected `http.globalAgent`) to native `fetch()`. However, Node.js's native `fetch()` does not respect `http.globalAgent`/`https.globalAgent` - it uses `undici` under the hood with its own connection handling. This broke proxy support for users behind corporate proxies. ## Solution - Add `undici` as a dependency to `@turbo/utils` - Implement `getProxyForUrl()` to detect proxy settings from environment variables (`http_proxy`, `HTTP_PROXY`, `https_proxy`, `HTTPS_PROXY`) - Implement `getProxyAgent()` with caching to avoid creating multiple `ProxyAgent` instances - Pass the `dispatcher` option to `fetch()` calls in `fetchWithTimeout()` and `streamingExtract()` ## Changes - `packages/turbo-utils/src/examples.ts`: Add proxy detection and `ProxyAgent` integration - `packages/turbo-utils/package.json`: Add `undici` dependency - `packages/turbo-utils/__tests__/examples.test.ts`: Add tests for proxy behavior ## Testing - Added tests verifying proxy agent is used when `https_proxy`/`HTTPS_PROXY` is set - Added test verifying no proxy agent is used when no proxy env vars are set - All existing tests continue to pass Fixes #11314 --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Author
Parents
Loading