Javascript 代理地址在本机客户端中不起作用

Javascript 代理地址在本机客户端中不起作用,javascript,react-native,react-native-android,Javascript,React Native,React Native Android,我正试图在我的第一个react本机应用程序(expo项目,在我的物理android设备上运行)中发出一个GET API请求。 我在尝试使用Axios发出get请求时遇到问题-我的后端在express中连接到Firebase DB。 {以下设置在react web app中运行良好} ... const handleSubmit = () => { const userData = { email: email, password: password

我正试图在我的第一个react本机应用程序(expo项目,在我的物理android设备上运行)中发出一个GET API请求。 我在尝试使用Axios发出get请求时遇到问题-我的后端在express中连接到Firebase DB。 {以下设置在react web app中运行良好}

  ... 
  const handleSubmit = () => {
    const userData = {
      email: email,
      password: password
    };
    axios.get('/alltests')
      .then((res) => {
        alert("Successfully loggedin", res)
        console.log(JSON.stringify(res.data))
      })
      .catch((err) => {
        console.log("\n\nI'm in error block - frontend")
        console.log(err)
        alert(err);
        //setErrors(err.response.data)
      })
     ...
My package.json看起来像->

  "dependencies": {
    "@material-ui/core": "^4.8.1",
    "@material-ui/icons": "^4.5.1",
    "axios": "^0.19.0",
    "cors": "^2.8.5",
    "expo": "~36.0.0",
    "react": "~16.9.0",
    "react-dom": "~16.9.0",
    "react-native": "https://github.com/expo/react-native/archive/sdk-36.0.0.tar.gz",
    "react-native-paper": "^3.4.0",
    "react-native-vector-icons": "^6.6.0",
    "react-native-web": "~0.11.7"
  },
  "devDependencies": {
    "babel-preset-expo": "~8.0.0",
    "@babel/core": "^7.0.0"
  },
  "private": true,
  "proxy": "https://asia-something.net/api"
}

然而,如果我使用 axios.get(“”) 这似乎在代码中起作用

我没有使用本地主机或在本地服务器上运行后端。
有人能帮我吗?

例如,尝试使用代理服务器的完整URL, 假设您的代理服务器URL为:
http://localhost:3000/alltest

不要使用
localhost
而是使用本地计算机IPV4/inet IP作为完整的请求URL,如下所示:
http://192.168.1.4:3000/alltest


通过从命令提示符/终端运行
ipconfig(windows)
ifconfig(mac/linux)
,您可以找到您的计算机本地IP(192.168.1.4)IPV4/inet地址。例如,尝试使用代理服务器的完整URL, 假设您的代理服务器URL为:
http://localhost:3000/alltest

不要使用
localhost
而是使用本地计算机IPV4/inet IP作为完整的请求URL,如下所示:
http://192.168.1.4:3000/alltest


通过从命令提示符/终端运行
ipconfig(windows)
ifconfig(mac/linux)
,您可以找到您的计算机本地IP(192.168.1.4)IPV4/inet地址。代理地址来自firebase,因此它不是本地主机的IP问题。此外,它的行为问题-不确定我是做错了还是应该这样做代理地址来自firebase,因此它不是本地主机v/s IP问题。此外,它的行为问题——不确定我是做错了还是注定要这样