How to develop locally using a domain name instead of ‘localhost:3000’ in the URL with create-react-app?

To develop locally using a domain name instead of ‘localhost:3000’ in the URL with create-react-app, we can edit the hosts file to map localhost to a URL.

For instance, in /etc/hosts, we add

127.0.0.1   somedomain.com

to map the localhost 127.0.0.1 IP address to somedomain.com.

Then we can open our app in the browser with somedomain.com:3000.