Rendering an environment variable to the browser in a react.js redux production build running in different environments

后端 未结 3 1058
时光取名叫无心
时光取名叫无心 2021-02-09 11:10

The readme of the react redux realworld.io application at https://github.com/gothinkster/react-redux-realworld-example-app says to edit the src/agent.js to change t

3条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-09 11:47

    You can replace the environment variables directly in your index.html file exposing a global ENV variable. That replacement needs to be done at runtime to make sure that you have a portable image that you can run in different environments.

    I have created an example repository here https://github.com/axelhzf/create-react-app-docker-environment-variables

提交回复
热议问题