0

I use create-react-app and trying to set HOST=custom.local variable with .env file. But it is always ignored with the message:

Attempting to bind to HOST environment variable: custom.localhost
If this was unintentional, check that you haven't mistakenly set it in your shell.

Also, I see this:

echo $HOST
M1-Air // <- my laptop name

So, how I understand this variable is already set and dotenv within CRA won't overwrite it and just ignores, but any suggestions on what I need to do to set my custom HOST variable for CRA anyway?

I've found a similar issue on GitHub but it doesn't have any suggestions on how to resolve it: https://github.com/facebook/create-react-app/issues/4307

jamland
  • 931
  • 15
  • 23

2 Answers2

0

Looks like my issue isn't caused by reassigning the variable, but because my custom hostname custom.localhost isn't mapped to any IP, even there is no such message.

Solved it by adding 0.0.0.0 custom.localhost in my /etc/hosts in addition to adding the domain to the .env file.

I've found the answer here: https://stackoverflow.com/a/52595624/344306

jamland
  • 931
  • 15
  • 23
0

edit in .env or maybe .config file and replace the given host to localhost or HOST=127.0.0.1, it will solve this issue

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jun 24 '22 at 18:52