Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does it work with Network Proxies #203

Open
madsteer opened this issue Jan 15, 2025 · 0 comments
Open

Does it work with Network Proxies #203

madsteer opened this issue Jan 15, 2025 · 0 comments

Comments

@madsteer
Copy link

How do you use cross-fetch in a node app where you need to use network proxies? For node-fetch@2 I can just

import { HttpsProxyAgent } from 'https-proxy-agent'

const proxyUrl = 'http://127.0.0.1:9000'
const agent = new HttpsProxyAgent(proxyUrl)

const res = await fetch('https://www.google.com', { agent })
. . .

when I replace node-fetch with cross-fetch on the import I get a type error on the { agent }

No overload matches this call.
  Overload 1 of 2, '(input: string | URL | Request, init?: RequestInit | undefined): Promise<Response>', gave the following error.
    Object literal may only specify known properties, and 'agent' does not exist in type 'RequestInit'.
  Overload 2 of 2, '(input: URL | RequestInfo, init?: RequestInit | undefined): Promise<Response>', gave the following error.
    Object literal may only specify known properties, and 'agent' does not exist in type 'RequestInit'.ts(2769)

Thanks,

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

No branches or pull requests

1 participant