Create React App: using environment variables in index.html : <p>Is there a way to inject environment variables, e.g. <code>REACT_APP_MY_API</code> into the <code>index.html</code> file? </p>

<p>According to <a href="https://github.com/facebook/create-react-app/pull/1440" rel="noreferrer">this</a>, it can be done, but I can't seem to get it to work. </p>

<h2>.env</h2>

<pre><code>REACT_APP_MY_API=https://something.com
</code></pre>

<h2>index.html</h2>

<pre><code>&lt;script type="text/javascript"&gt;
  console.log("%REACT_APP_MY_API%") // undefined 
  console.log("%NODE_ENV%") // development
&lt;/script&gt;
</code></pre>
