FAQ | This is a LIVE service | Changelog

Skip to content

replace build-time .env configuration with run-time config.js file

Dr Rich Wareham requested to merge github/fork/rjw57/runtime-configuration into master

Application configuration via .env files had the advantage that the configuration was baked into the production app at npm build time. This was also a disadvantage since some configuration differes between releases (test, production, etc) and we'd like to use the same application image to serve them if possible.

Move existing uses of the REACT_APP_... environment variables over to a new configuration object which is initialised at runtime and may be overridden both locally in development and in production by adding a line to index.html. See the README.md changes for more details.

For the test suite, there is no browser and index.html is not loaded. In this case the configuration is loaded from the default export of the src/test/config.js module instead.

To use the configuration mechanism, import the src/config.js module. This module's default export is the application configuration and the implementation of the module takes care of returning the global variable from window or the test configuration as appropriate.

Merge request reports

Loading