At some point I needed to add a configuration variable containing the client_id for Google API. The config is needed in React part of the app and it should be different depending on the environment (dev & test, prod). Ideally, it should be stored outside of the Git repository.
The problem is that it doesn’t work:
What solution would you recommend for the Phoenix and React app?
The roughly equivalent call for Elixir on the server side is System.get_env. That let you should see your client ID as you’ve set it on your mix line. Transferring that securely to the browser would probably involve using HTTPS or some other encryption in a server to client transfer step (say an API call).
That being said recommended practice is to limit the reliance on environment variables to one, single variable typically process.env.NODE_ENV - which is then used to select the correct module (e.g. settings.prod.js vs. settings.dev.js) to include in the generated JS bundle.