Runtime environment variables
Regarding this [pull request](https://github.com/facebookincubator/create-react-app/pull/1344#issuecomment-302887448) around the improvements to environment variables, based on @gaearon's suggestion, I wanted to start a discussion on how to handle a docker-centric, 12 factor app-based workflow where environment variables are provided externally at runtime rather than at build time so that the exact same assets can be run in multiple environments. Constraints / design goals mentioned is: > It's important though to note that CRA always produces static bundles, and they are expected to work in any environment regardless of server, container, etc. In the past, I have implemented the following two solutions: 1) render environment variables into the HTML and then hoist them into an application at initialization 2) fetch environment variables from a server (for example, before creating the store and rendering the app with some static content during the initial fetch) The first solution's benefit is that there is no delay before initial render, but with create react app dynamically modifying the html file, it becomes a little more tricky to implement since you would need to parse or search / replace within the rendered html before serving the file. I'm just wondering if there is a better / best way to provide runtime environment variables to CRA applications and if we can get agreement on an approach, if it can be integrated into the CRA pipeline. Thank you for all the great w
Posted by kmalakoff on May 24, 2017, 5:39 PM
Tags
Related issues
- 2026 - Microsoft Office 365
- [Ubuntu] `ubuntu-latest` label will use Ubuntu 26.04 in November 2026
- Gamut mapping
- [Codex Desktop] Editing and resending a queued message triggers "App-server queued follow-up no longer exists"
- [Windows] ChatGPT 26.820.60940 fails with "invalid transport in mcp_servers.codex_app"; Beta 26.727.40816 works
- [BUG]: infinite loading of videos
Raise real-world problems, find people facing the same issue, and discuss solutions.4,500 issues0 comments
github (SaaS)
2026 - Microsoft Office 365
[Ubuntu] `ubuntu-latest` label will use Ubuntu 26.04 in November 2026
Gamut mapping
[Codex Desktop] Editing and resending a queued message triggers "App-server queued follow-up no longer exists"
[Windows] ChatGPT 26.820.60940 fails with "invalid transport in mcp_servers.codex_app"; Beta 26.727.40816 works
[BUG]: infinite loading of videos
Restore GPT-5.6 Sol’s 372k Codex context window, or provide an opt-in setting
Codex Desktop for macOS repeatedly triggers `syspolicyd` / `trustd` CPU and memory runaway
Runtime environment variables
Regarding this [pull request](https://github.com/facebookincubator/create-react-app/pull/1344#issuecomment-302887448) around the improvements to environment variables, based on @gaearon's suggestion, I wanted to start a discussion on how to handle a docker-centric, 12 factor app-based workflow where environment variables are provided externally at runtime rather than at build time so that the exact same assets can be run in multiple environments. Constraints / design goals mentioned is: > It's important though to note that CRA always produces static bundles, and they are expected to work in any environment regardless of server, container, etc. In the past, I have implemented the following two solutions: 1) render environment variables into the HTML and then hoist them into an application at initialization 2) fetch environment variables from a server (for example, before creating the store and rendering the app with some static content during the initial fetch) The first solution's benefit is that there is no delay before initial render, but with create react app dynamically modifying the html file, it becomes a little more tricky to implement since you would need to parse or search / replace within the rendered html before serving the file. I'm just wondering if there is a better / best way to provide runtime environment variables to CRA applications and if we can get agreement on an approach, if it can be integrated into the CRA pipeline. Thank you for all the great w
Comments (0)
No comments yet. Start the discussion.