0

I'm trying to use proxy with my react-native app (build with CRNA and Expo). So in my package.json file I put : "proxy": "192.168.1.27:8080" and then make simple get request with fetch with the/users` path and react call me network error (he don't see the proxy param, just /users when I'm debugging). The fetch request work well if I put the full url. In react (for website) I do the same thing and that's work to.

Thank's for your help.

sayenel
  • 31
  • 4

1 Answers1

0

In Reactjs proxies are mainly used to avoid cors issues. Since React Native connects to iOS & Android natively, there is no browser issue so you don't need a proxy.

The approach I use is to call http:127.0.0.1:nnnn/api/route (not localhost) in the React Native app when testing the backend, and the deployed url in production. So you can deploy your server separately and reach it directly in the app.

stever
  • 1,232
  • 3
  • 13
  • 21