4

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?

1
  • If you want to set an env var you need to do it first, that's just passing some unhandled arguments to react-scripts. Commented Apr 17, 2021 at 7:28

1 Answer 1

3

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.