Mockoon offers the possibility to access environment variables in your templates using the getEnvVar
helper. This allows you to avoid exposing your API keys and certificates in your mock server configuration.
Environment variables are accessible everywhere templating helpers are supported.
By default, only the environment variables prefixed with MOCKOON_
are available, for example, MOCKOON_MY_VARIABLE
. You can access the variable in your templates using the getEnvVar
helper:
Copy
You can change the prefix or remove it entirely in the application settings:
Removing the prefix will make all the environment variables accessible in your templates.
💡 Both the CLI and the serverless library have specific options to customize the prefix.