title: Why process.env variable shows undefined in index.html ReactJS
body: <p>I want to access process.env from index.html using the below code:</p>
  <pre><code> &lt;script&gt;
        const process;
        process.env = {
          API_ENDPOINT: &quot;%REACT_APP_API_ENDPOINT%&quot;,
        };
      &lt;/script&gt; 
  </code></pre>
  <p>I get error, process not defined and api url in networks shows &quot;localhost:3000/undefined&quot;. I can access window.env from here but not process.env from index.html file.</p>
  <p>I can access the process.env directly in my service.js file using below code:</p>
  <pre><code>getNetworkProducts: async (reqParams) =&gt; {
          const res = await axios.get(
            process.env.REACT_APP_API_ENDPOINT + reqParams
          );
          return res;
        },
  </code></pre>
  <p>I do not want to append REACT_APP to API_ENDPOINT when I make a service call. Is there anyway that I can handle that from index.html without making changes in all of my services.</p>
  <p>my package.json looks like this:</p>
  <pre><code>&quot;dependencies&quot;: {
      &quot;@okta/okta-auth-js&quot;: &quot;^5.4.0&quot;,
      &quot;@okta/okta-react&quot;: &quot;^6.1.0&quot;,
      &quot;axios&quot;: &quot;^0.21.1&quot;,
      &quot;dotenv&quot;: &quot;^10.0.0&quot;,
      &quot;env-cmd&quot;: &quot;^10.1.0&quot;,
      &quot;react&quot;: &quot;^16.13.1&quot;,
      &quot;react-apexcharts&quot;: &quot;^1.3.9&quot;,
      &quot;react-dom&quot;: &quot;^16.12.0&quot;,
      &quot;react-router-dom&quot;: &quot;^5.1.2&quot;,
      &quot;react-scripts&quot;: &quot;^3.4.3&quot;,
    },
    &quot;scripts&quot;: {
      &quot;start&quot;: &quot;env-cmd -f ./.env.development react-scripts start&quot;,
      &quot;build&quot;: &quot;env-cmd -f ./.env.production CI=false &amp;&amp; react-scripts build&quot;,
      &quot;test&quot;: &quot;env-cmd -f ./.env.development react-scripts test&quot;,
      &quot;test:nowatch&quot;: &quot;react-scripts test -- --coverage --watchAll=false&quot;,
      &quot;eject&quot;: &quot;react-scripts eject&quot;
    },
  </code></pre>