Combine Nodejs + React Native + Axios + CORS

人走茶凉 提交于 2019-12-01 20:19:45

ANSWER :

Alright, after few hours working on that bug, I found the answer by my self. The thing is that my server Node.js is running on my PC and I am testing my app with Expo on my cellphone. I was calling the server from the front-end with Axios with url http://localhost:3001/login. As I can't reach localhost of my PC with my cellphone, I had to change the url for the IP address of my PC, http://192.168.0.123:3001/login.

Here's how to get your IP address of your PC : Calling locally hosted server from Expo App

Here's a similar problem : Axios (in React-native) not calling server in localhost

Hope it can help someone in the future with a similar bug.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!