通过代理获取React-Native [英] React-Native fetch through proxy
本文介绍了通过代理获取React-Native的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在react-native的fetch
方法中设置选项以通过代理对Web服务器进行调用.
How can I set options in the fetch
method of react-native to make a call to a webserver go through a proxy.
当前,我正在使用 axios ,但这是行不通的.
Currently I am using axios but this doesn't work.
在将主机标头添加到提取中之后,我可以通过charles-proxy发出请求,但不适用于squid. (Error: invalid url
).
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
).
推荐答案
在您的react项目中存在的package.json文件中,您可以创建如下所示的代理:
Inside your package.json file that exists in your react project you can create a proxy like the following:
"proxy": "http://localhost:5000"
这篇关于通过代理获取React-Native的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文