Designing for multiple environments
When running your application in different environments, like those provided by Release, you may need to make some minor changes to your code to support multi-variations. You may need to adapt your code depending on how your framework handles CORS, or you may want to support frontends pointing to different instantiations of a backend. Release provides several environment variables to use in your application to assist you to properly configure your application to work in multiple environments.
Release provides the following environment variables:
RELEASE_ENV
: set totrue
for all Release environmentsSERVICE_INGRESS_URL
: whereSERVICE
is the name of your service, includinghttps://
SERVICE_INGRESS_HOST
: whereSERVICE
is the name of your service, no protocol addedRELEASE_RANDOMNESS
: the random unique portion of the URL
For example, the following code configures CORS in Django:
Applications with a frontend and backend
If your app uses a JavaScript framework, such as React, on the frontend, and Rails on the backend, you will need to configure the Rails backend to allow traffic from the frontend. You will also need to configure the frontend to talk to the backend.
In the following example, a Rails backend service named backend
is configured to allow traffic from a React frontend service named frontend
:
Release will generate the following environment variables to use in your application:
FRONTEND_INGRESS_URL
FRONTEND_INGRESS_HOST
BACKEND_INGRESS_URL
BACKEND_INGRESS_HOST
Now we need to configure the frontend service to talk to the backend. Here we configure Axios to talk to our backend:
Last updated