-
Notifications
You must be signed in to change notification settings - Fork 7
Description
Issue: Environment Variable Misconfiguration Prevents Running bun run start Effectively
Context
When attempting to run the development server using bun run start in the packages/demo directory, the process fails or does not behave as expected due to a missing environment variable.
The .env.example file currently suggests that the required environment variable is named:
BLOCKFROST_API_KEY
and instructs users to create a .env.local (or equivalent) file including this variable.
Problem
-
The variable
BLOCKFROST_API_KEYis not actually used in the codebase. -
Instead, the code expects two separate environment variables to be set for API keys:
BLOCKFROST_API_KEY_PREVIEWBLOCKFROST_API_KEY_MAINNET
-
Because only
BLOCKFROST_API_KEYis indicated in.env.exampleand expected in.env.local(or in an equivalent file), the app does not receive the correct keys and cannot start properly. -
On top of that, the current setup doesn't automatically load variables
Proposed Changes
-
Update the start script in
packages/demo/package.jsonChange from:
"start": "NODE_ENV=development webpack serve --env local --open --config ./webpack.config.cjs",
to
"start": "NODE_ENV=development dotenv -e .env.local webpack serve --env local --open --config ./webpack.config.cjs",
This ensures that the environment variables defined in .env.local are loaded properly when running the start command.
- Revise
.env.exampleto reflect the correct environment variables
Replace the current content with:
BLOCKFROST_API_KEY_PREVIEW=
BLOCKFROST_API_KEY_MAINNET=
This clarifies which keys need to be set by the user and aligns the example file with the actual variables used in the code.
Summary
- The current
.env.exampletemplate is misleading with the naming conventionBLOCKFROST_API_KEY. - There is no working mechanism to successfully load env vars from .env* files.
- The code requires
BLOCKFROST_API_KEY_PREVIEWandBLOCKFROST_API_KEY_MAINNET. - Updating the start script to load
.env.localexplicitly and correcting the.env.examplefile will resolve the issue and improve developer experience.
Thank you for considering this fix to improve the clarity and functionality of the environment setup.
P.S. I wanted to add a MR with a proposed changes, but it appears that an access needs to be granted.