Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React-Native fetch through proxy

How can I set options in the fetch method of react-native to make a call to a webserver go through a proxy.

Currently I am using axios but this doesn't work.

After adding a host header to the fetch, I can make a request through charles-proxy but it doesn't work with squid. (Error: invalid url).

like image 965
Felix Bäder Avatar asked Sep 12 '25 12:09

Felix Bäder


1 Answers

You can solve this by installing local-cors-proxy globally and run it by

npm install -g local-cors-proxy

Start Proxy:

lcp --proxyUrl https://www.yourdomain.ie

Then in your client code, new API endpoint:

http://localhost:8010/proxy/movies/list

Package: https://www.npmjs.com/package/local-cors-proxy

like image 59
Jijo Bose Avatar answered Sep 14 '25 05:09

Jijo Bose