Environment variable mappings
Why and how to use environment variable mappings
There are many reasons you may want to use environment variables in your application, for example, to provide a backend URL for your frontend.
Here is an example config.js
for a React application:
In this example, Release will autogenerate ingress URLs for the application to expose ports:
In order for the frontend application to use the URLs autogenerated by Release, you can map the application's environment variables to the autogenerated environment variables. You can map environment variables in an application's default environment variables or in the environment-specific environment variables.
Here is an example environment variable mapping:
Mappings are expressed as key-value pairs, with the application's environment variable as the key and the Release autogenerated environment variable as the value.
Interpolation
Environment variable mappings are also the only place where interpolation can occur. You can try to interpolate variables together to create a new string:
You can also use bash interpolation rules for fallback if the variables are not present. As an example, your frontend may use an app import to connect to a backend. If the backend is not present, however, it can fallback to a staging environment.
Deploy Your Changes
Once you have added your environment variable mapping, save the configuration and deploy.
Last updated