Environment variables are set from the local shell (or CI shell) or can be provided from a file.
Environment files take precedence over shell environment variables during developer portal builds.
The benefits of using a file is keeping them centrally organized in source control. The drawback is you should not keep any secrets in the file (or in source control). Environment variable files are only usable with developer portals (not with the API registry).
Your environment files must:
- be in the root of your project repository
- start with
- end with the environment's name (eg.
Example environment file names:
Example environment file contents:
MY_ENV_VAR=yes PRIMARY_COLOR=orange WELCOME_MESSAGE=Welcome
Never store credentials or any kind of sensitive data in your environment files.
By default, Redocly will use
.env.development for your local development server, and
.env.production in our production build.
To determine which environment file is used, set the environment variable named
REDOCLY_ACTIVE_ENV to the value of the environment.
REDOCLY_ACTIVE_ENV should be set by shell (for on-premise or local development) or in Workflows.
Setting environment variables in your shell is operating system-specific (check your corresponding operating system documentation for setting environment variables).
Given this environment variable setting (
REDOCLY_ACTIVE_ENV=production-example), Redocly would look for the
.env.production-example in your project root.
Restart your development server if you change your environment variables.
All variables in the file are automatically allowed to be used in the client-side developer portal app.