Create React App: using environment variables in index.html

后端 未结 4 1208
予麋鹿
予麋鹿 2021-02-03 18:00

Is there a way to inject environment variables, e.g. REACT_APP_MY_API into the index.html file?

According to this, it can be done, but I can\'

4条回答
  •  迷失自我
    2021-02-03 18:29

    Make sure you restart your create-react-app when adding variables into the .env file

    Also make sure you have >= react-scripts@0.9

    I use .env variables for the meta title of a site with various language versions of the build:

    %REACT_APP_SITE_TITLE%

提交回复
热议问题