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

proxy for isomorphic-fetch #171

Open
steeply opened this issue Jul 8, 2018 · 3 comments
Open

proxy for isomorphic-fetch #171

steeply opened this issue Jul 8, 2018 · 3 comments

Comments

@steeply
Copy link

steeply commented Jul 8, 2018

Prompt how to use isomorphic-fetch together with a proxy?


import fetch from 'isomorphic-fetch';

options = {
      method,
      timeout,
      headers: {
        'Cache-Control': 'no-cache',
        'Content-Type': 'application/json; charset=utf-8',
        'proxy': ?????
      },
      body: JSON.stringify(data)
    };
return fetch(url, options)
@mdogadailo
Copy link

I think you can't use proxy with client implementation. But for server version:

import fetch from 'isomorphic-fetch';
import proxyAgent from 'http-proxy-agent';
//import proxyAgent from 'https-proxy-agent'; // HTTPS

const options = {
	method: 'GET',
	agent: new proxyAgent('http://proxy:8080'),
	body: JSON.stringify(data)
};

fetch(url, options)

@jimmywarting
Copy link

jimmywarting commented Jan 25, 2019

did agent and http-proxy-agent solve it? can this be closed now?

@pkvpraveen
Copy link

It did solve for me.

import fetch from 'isomorphic-unfetch';
import HttpsProxyAgent from 'https-proxy-agent';
const res = await fetch('http://api.tvmaze.com/search/shows?q=batman', {agent: new HttpsProxyAgent('<myproxy>')});

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

4 participants