0

I have a .sh file with the follow code:

react-scripts start HOST=0.0.0.0

And my yarn start scripts is:

"scripts": {
"start": "./run.sh",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"

},

The problem is that when I access to process.env object on a react component, I don't see this variable. How can I do this to work?

jonrsharpe
  • 99,167
  • 19
  • 183
  • 334
  • If you want to set an env var you need to do it _first_, that's just passing some unhandled arguments to react-scripts. – jonrsharpe Apr 17 '21 at 07:28

1 Answers1

0

This seem to work for me: Setting environment variables in a shell script for a React app

So the solution is to add REACT_APP as prefix of your variables.

My .sh file ended like this:

#!/bin/sh
export REACT_APP_PYTHON_API_IP="localhost"
yarn start