Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • C create-react-app
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 1,547
    • Issues 1,547
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 417
    • Merge requests 417
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Meta
  • create-react-app
  • Issues
  • #12824
Closed
Open
Issue created Nov 04, 2022 by Administrator@rootContributor

Add support for default expansion of environment variables by bumping dotenv-expand dependency

Created by: hovsater

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.

Assignee
Assign to
Time tracking