Skip to content
This repository was archived by the owner on Jun 11, 2022. It is now read-only.
This repository was archived by the owner on Jun 11, 2022. It is now read-only.

Env vars are compiled into app #7

Closed
@mars

Description

@mars

Updated Oct 16, 2016 with the final solution

Problem

When using the REACT_APP_* or NODE_* environment vars to configure the React app, a rebuild (git push heroku master) is required for changes to take effect. These values get embedded in the JavaScript bundle during build, whereas Heroku apps should always read config from environment variables.

Examples of issues this causes:

  • when using pipelines, promoting an app (e.g. from staging to production) will not pick-up new values for these variables (until a new build is triggered)
  • when setting config vars, the value is not applied immediately; the app must be re-deployed to pick-up the new config value
  • in general, slugs are no longer reusable per Heroku's standard architecture

Proposal

Perform replacement of environment variables in the bundle during the app start-up (via .profile.d/ script), so that the current environment variables are used at runtime.

Caveats

Try it

Try the proposed runtime env vars strategy by using the buildpack branch:

heroku buildpacks:set https://github.com/mars/create-react-app-buildpack.git#modular-runtime-env-vars

Then, follow the new Runtime vs Compile-time docs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions