Configuration
Environment Variables
Environment Variables allow apps to access custom configuration at the individual app level. They are available in all non static Micros during runtime. You can create custom environment variables for your app that can be modified by the end user of the app, while Micros also come with pre-set Space system variables.
Custom Variables
Use the env
preset in the Spacefile
if you need to set custom environment variables for your Micros. This can be used to let users of your app specify things like external secrets, API Keys, or Data Keys of different app instances.
name
: environment variable name or keydescription
: human friendly description (optional)default
: default value for the variable (optional)
The user of the app will be shown a UI in the App’s Settings where they can set the values for the specified environment variables. They will be exposed to the Micro’s environment under the specified name
. For development instances of your projects, these environment variables can also be fetched and/or updated directly with space-cli
.
When developing locally using space dev
, any custom environment variables that exist in the current shell environment will be passed through to the development environment, overwriting the default
value.
Pre-set Variables
Micros also come pre-set with environment variables, accessible on the server side of every Micro. The following variables are available:
DETA_PROJECT_KEY
: a Data KeyDETA_SPACE_APP
: will be set to“true”
DETA_SPACE_APP_VERSION
: the app versionDETA_SPACE_APP_HOSTNAME
: will be set to the primary hostnameDETA_SPACE_APP_MICRO_NAME
: your Micro’s nameDETA_SPACE_APP_MICRO_TYPE
: will be set to"primary"
if primary otherwise“normal”
PORT
: the port Space will route requests to on your Micro
Please let us know if you need additional configuration.