I have a react app running on localhost port 3000 but instead of using localhost:3000 I would like to set a custom domain name to mydomain.com. I did already the change in the windows host file to
127.0.0.1 mydomain.com
but I guess I have to specify in my react app to look into this domain instead of localhost. How can I do this?
I tried : "start": "set HOST=videowall.com && set PORT=3006 && react-scripts start",
but it is returning
Error: getaddrinfo ENOTFOUND videowall.com
You need add this line to your hosts file:
/etc/hosts
C:\Windows\System32\Drivers\etc\hosts
127.0.0.1 videowall.com
NOTE: If you need access this out of your development machine like me change 127.0.0.1
to 0.0.0.0
.
Use .env
file in root of your React project instead of export/set envs, with this content:
HOST='videowall.com'
PORT=3006
That's it.
Make the following change in your package.json file
"start": "HTTPS=true HOST=mycompany.com PORT=3001 react-scripts start",
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With