"scripts": {
"start": "cross-env NODE_PATH=src react-scripts start",
"build": "cross-env NODE_PATH=src react-scripts build",
}
How do I change localhost:3000 to custom.domain in react
You can't change localhost to mydomain.com in local development. Your react app is available in your own browser thanks to a local dev server powered by Webpack (it's made under the hood of your Create React App).
If you want a custom domain, you will need to host your code on a server. The server will have an IP address. You can then attach a custom domain name to it through any provider.
When a user tries to access your website, he will send a request to a DNS server, that will find the correct IP bound to your custom domain name and then send him back the code to display your website.
If you are asking about purely locally serving your application you can simply append a HOST value before the script. Much like others have pointed out you can do with a PORT value.
"scripts": {
"start": "HOST=custom.domain react-scripts start"
}
Then on your machine you will just need to ensure that you have configured your hosts files with the appropriate directive
127.0.0.1 custom.domain
Assuming you have run the start script and are serving the site you can now access it via the url http://custom.domain:3000
If you want to change domain you need to upload your react app to web space. If you want to change port you need to send argument in start script.
"scripts": {
"start": "set port=4213 && react-scripts start",
}
In this case port will be 4213. So site will run on http://localhost:4213