How can I develop locally using a domain name instead of 'localhost:3000' in the url with create-react-app?

后端 未结 4 1546
野性不改
野性不改 2021-01-13 07:26

I have been developing a small app with create-react-app and a few other libraries i added. Given the planned architecture and some tests i\'d like to run with react-router,

4条回答
  •  清歌不尽
    2021-01-13 07:40

    You can do it by updating your hosts file with the following entry

    127.0.0.1 somedomain.com

    and then use somedomain.com to access your site

    But if somedomain.com happens to be your actual host address then you will have to revert it back when you want to connect to the actual hosted somedomain.com

    You can find more info about how to edit your host file here: https://www.siteground.com/kb/how_to_use_the_hosts_file/

    There a similar answer which you can find here: Assigning a domain name to localhost for development environment

提交回复
热议问题