Help

Accessing .env variables in Custom App

Topic Labels: Custom Extensions
1546 0
cancel
Showing results for 
Search instead for 
Did you mean: 
Matthew_Thomas
7 - App Architect
7 - App Architect

This previous post details accessing the special NODE_ENV environment variable within a Custom App.

This is all well and good, but leaves me wondering if it’s possible to store/access custom environment variables through a custom app? Reading through the documentation/tutorials at Create React App, my guess is this is not currently possible in a Custom App because it’s run using block run instead of react-scripts and npm start? Attempting this by adding .env files in both the root directory ({block_name}/) and entry point ({block_name}/frontend) and running a console.log outputs undefined in the inspector.

Am I correct in assuming that accessing .env variables (besides NODE_ENV) is not currently possible? Does anyone have any good workarounds/alternative solutions? At the moment, I’m just defining these variables as constants in their respective files.

(For reference, I’m looking to use .env variables for two main use cases. 1) development vs. production server endpoint to send API requests; and 2) Airtable base IDs for development/production, so testing doesn’t affect in-use bases.)

0 Replies 0