Accessing .env variables in Custom App

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.)

This topic was solved and automatically closed 15 days after the last reply. New replies are no longer allowed.