Skip to content

Does it work with Network Proxies #203

Open
@madsteer

Description

@madsteer

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,

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions