Environment Variables
Freestyle allows you to set environment variables independently for your cloudstate and web server environments. This is useful for isolating secrets and only exposing them to the necessary parts of your application.
Setting Environment Variables
To set environment variables for your freestyle project, you can use the env
key in your freestyle.config.ts
file. This key should be an object where the keys are the environment variable names and the values are the environment variable values.
Using .env Files
Freestyle does not automatically load .env files. If you want to use .env files, you can use a package like dotenv
to load the .env file and set the environment variables in your freestyle.config.ts
file.
- First, install the
dotenv
package: - Add the following code to the top of your
freestyle.config.ts
file: - Now you can use the environment variables in your
freestyle.config.ts
file.