0

I'm working on a React Native app, and whenever I need to deploy to production on Play Store and App Store, I have to remember to manually switch the value of a string variable from 'dev' to 'prod', which defines the backend Url that the app is using. The problem is that if I forget to do so, the clients will use an app that points to the testing backend, which, of course, is terrible.

Question: Is there a manner to guarantee that I don't accidentally deploy the app with the testing backend ? I need a way to completely isolate the testing and production environments.

joaoricardotg
  • 137
  • 3
  • 9
  • 2
    Does this answer your question? [React-native : detect dev or production env](https://stackoverflow.com/questions/34315274/react-native-detect-dev-or-production-env) – Abe Sep 01 '22 at 19:49
  • It would be a solution if I used the terminal to generate new builds – joaoricardotg Sep 01 '22 at 19:54
  • can you add the file/code where you are switching the string value? How are you generating builds? `-dev=false` is passed automatically when building for production – Abe Sep 01 '22 at 20:14
  • I'm using the Android Studio interface to generate a signed bundle. So basically: > Build > Generate Signed Bundle/APK > Android App Bundle. – joaoricardotg Sep 02 '22 at 22:57
  • `__DEV__` should be false in your finished bundle, have you been able to test that? – Abe Sep 02 '22 at 23:39

1 Answers1

0

is the DEV_ constant to do something like this

const baseUrl = __DEV__ ? 'stagingURL' : 'prodUrl';

export baseUrl

then always import baseUrl when using an endpoint

there are certainly more completed ways of doing this (to solve other needs) like building multiple targets(IOS) and flavors(android) of your app, but this is what you need for now

Walter Shub
  • 652
  • 8
  • 19