Accessing AppFlow environment keys from Ionic 4/5/6 apps

Might be a stupid question but I’d like to store some API keys as key values in AppFlow Environment variables such as

TEST
api_endpoint:  https://whatever.com
client_key: "12345"

PRODUCTION
api_endpoint:  https://whateverelse.com
client_key: "98765"

The Appflow docs here state I can get to those values in my source code but only in an Ionic 3 app.

What’s the method for this in Ionic 4 and beyond? I realise I can access them from the build scripts in package.json to swap environment files but what’s the advantage of storing actual keys in AppFlow Environments rather than in environment files in the app?

Hi @richardshergold,

There are a number of advantages for storing keys in Appflow. One quick example is that the keys are never stored in the actual code which in turn adds a layer of security.

As for a method for Ionic 4 and beyond, I would look toward using a prebuild script that generates the environment file as you have described.

If you have any additional questions for this topic, please do reach out to Appflow support for further assistance. Thanks!

1 Like