Configure environment files
To configure environment files for the clinical web apps, follow these steps:
1. Locate the Environment Files
Environment files are typically located in the root directory of your project. Common filenames include .env, .env.local, or .env.production.
2. Define Environment Variables
Open the environment file and define the necessary variables. For example:
REACT_APP_API_URL=https://api.example.com
REACT_APP_FEATURE_FLAG=true
3. Use Environment Variables in Code
Access the variables in your application code using process.env. For example:
const apiUrl = process.env.REACT_APP_API_URL;
console.log(`API URL: ${apiUrl}`);
4. Secure Sensitive Information
Do not commit sensitive environment files to version control. Add them to your .gitignore file:
.env
.env.local
5. Share Environment Configuration
Use a template file like .env.example to share the required variables with your team:
REACT_APP_API_URL=
REACT_APP_FEATURE_FLAG=
6. Test the Configuration
Restart your development server and verify that the environment variables are loaded correctly.
By following these steps, you can ensure a consistent and secure configuration for your environment files.