-
-
Notifications
You must be signed in to change notification settings - Fork 27.1k
Description
Is your proposal related to a problem?
Sometimes you may depend on environment variables in some way and may want to provide a default value in case one is not set. For instance, we have an API gateway that we need to configure locally and it's based on the current URL. In .env
we set it up as follows:
REACT_APP_API_GATEWAY_BASE_URL=localhost:${PORT}
This works as long as PORT
is set. create-react-app
defaults to port 3000
in case it's not set. Ideally, we'd like to express that in our .env
file using default expansion:
REACT_APP_API_GATEWAY_BASE_URL=localhost:${PORT:-300}
Unfortunately, this doesn't work as the current version of dotenv-expand does not support it. Default expansion was introduced in 6.0.0
.
Describe the solution you'd like
Consider bumping dotenv-expand (and by extension, dotenv) to at least version 6.0.1
to add support for default expansion (e.g., ${VAR:-DEFAULT}
. This is helpful when you want to provide a default value in case an environment variable isn't set.
Describe alternatives you've considered
None.
Additional context
None.