{"id":47662,"library":"fetch-with-proxy","title":"fetch-with-proxy","description":"A wrapper around node-fetch that automatically uses HTTP(S) proxy settings from environment variables (HTTP_PROXY, HTTPS_PROXY, ALL_PROXY, NO_PROXY). Version 3.0.1, stable, low maintenance. Unlike tunnel-based solutions (e.g., request, proxy-agent), it uses direct HTTP connections without CONNECT tunneling for HTTP targets, which avoids certain compatibility issues but may not support HTTPS proxying. It is a thin wrapper, passing through most node-fetch API behavior.","status":"active","version":"3.0.1","language":"javascript","source_language":"en","source_url":"https://github.com/touv/node-fetch-with-proxy","tags":["javascript","http","fetch","proxy"],"install":[{"cmd":"npm install fetch-with-proxy","lang":"bash","label":"npm"},{"cmd":"yarn add fetch-with-proxy","lang":"bash","label":"yarn"},{"cmd":"pnpm add fetch-with-proxy","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core dependency: fetch-with-proxy wraps node-fetch to add proxy support.","package":"node-fetch","optional":false}],"imports":[{"note":"ESM-only since v3.0.0. For CommonJS, use dynamic import or switch to CJS-compatible version.","wrong":"const { default: fetch } = require('fetch-with-proxy')","symbol":"default","correct":"import fetch from 'fetch-with-proxy'"},{"note":"Types are re-exported from node-fetch, but directly importing from node-fetch is safer.","wrong":"import { RequestInit } from 'fetch-with-proxy'","symbol":"RequestInit","correct":"import type { RequestInit } from 'node-fetch'"},{"note":"fetch-with-proxy does not re-export Headers, Response, etc. Import from node-fetch.","wrong":"import { Headers } from 'fetch-with-proxy'","symbol":"Headers","correct":"import { Headers } from 'node-fetch'"}],"quickstart":{"code":"import fetch from 'fetch-with-proxy';\n\nconst url = 'https://example.com';\nconst proxyUrl = process.env.HTTP_PROXY || 'http://proxy.example.com:8080';\n\n// The proxy is detected from environment variables automatically.\n// Example: set HTTP_PROXY=http://proxy.example.com:8080\nfetch(url)\n  .then(response => response.text())\n  .then(body => console.log(body))\n  .catch(err => console.error(err));","lang":"javascript","description":"Demonstrates default import and automatic proxy detection from environment variables."},"warnings":[{"fix":"Use dynamic import: const fetch = await import('fetch-with-proxy'); or downgrade to v2.x if CJS required.","message":"v3.0.0 dropped CommonJS support; now ESM-only.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Use a tunnel-based library like https-proxy-agent if you need full CONNECT tunneling.","message":"Does NOT support CONNECT tunneling for HTTPS proxies when fetching HTTP URLs. Only HTTP-to-HTTP and HTTPS-to-HTTPS (via agent) proxying.","severity":"gotcha","affected_versions":"all"},{"fix":"Upgrade node-fetch to v3 or stay on fetch-with-proxy v2 which supports node-fetch v2.","message":"node-fetch v2 is deprecated; fetch-with-proxy v3 requires node-fetch v3 (ESM).","severity":"deprecated","affected_versions":">=3.0.0"},{"fix":"Explicitly set headers if required.","message":"Does not set any default User-Agent header; relies on node-fetch defaults.","severity":"gotcha","affected_versions":"all"},{"fix":"Restart process if environment changes, or use custom agent for dynamic proxy.","message":"Proxy environment variables are read only once at startup, not on each request.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"search_vec":"'3.0.1':30 'agent':43 'api':77 'around':7 'automat':12 'avoid':56 'base':37 'behavior':78 'certain':57 'compat':58 'connect':48,50 'direct':46 'e.g':39 'environ':19 'fetch':2,10,76,81 'fetch-with-proxi':1 'http':14,21,47,53,80 'https':23,64 'issu':59 'javascript':79 'low':32 'mainten':33 'may':61 'node':9,75 'node-fetch':8,74 'pass':71 'proxi':4,16,22,24,26,28,42,65,82 'proxy-ag':41 'request':40 'set':17 'solut':38 'stabl':31 'support':63 'target':54 'thin':69 'tunnel':36,51 'tunnel-bas':35 'unlik':34 'use':13,45 'variabl':20 'version':29 'without':49 'wrapper':6,70","created_at":"2026-06-07T16:52:39.181979+00:00","updated_at":"2026-06-07T16:52:39.181979+00:00","problems":[{"fix":"Add \"type\": \"module\" to package.json or use .mjs extension, or use dynamic import.","cause":"ESM import used in a CommonJS project without appropriate configuration.","error":"SyntaxError: Cannot use import statement outside a module"},{"fix":"Use import fetch from 'fetch-with-proxy' (ESM) or const fetch = (await import('fetch-with-proxy')).default; for CJS.","cause":"Incorrect import path or using v3 as require().","error":"TypeError: fetch is not a function"},{"fix":"Use an HTTPS URL or switch to a tunnel-based proxy agent.","cause":"Trying to fetch an HTTP URL through an HTTP proxy that doesn't handle CONNECT.","error":"Error: Invalid protocol: http:"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/touv/node-fetch-with-proxy#readme","github":"https://github.com/touv/node-fetch-with-proxy","docs":null,"changelog":null,"pypi":null,"npm":"fetch-with-proxy","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}