score:1

you need to integrate variable with start script.

"scripts": {
    "start": "react_app_api_url=http://localhost:3001 react-scripts start", //like this
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  }

then you need to run your app. it will take all paramerters.

or another way to run it pass it using command line. ex: you need to pass env variable first before loading scripts

react_app_api_url=http://localhost:3001  npm start 

you can also use package for better env management(cross-env) it will take care all env related management. feel free to check there doc.

if you want to use cross-env you have to only do this for running enviornment from .env file(note:.env file should be on package.json level)

"scripts": {
    "start": "cross-env react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },

it will load all your configuration from .env file whenever you want to use.


Related Query

More Query from same tag