英文:
Why couldn't I can change my localhost to custom domain name in ReactJS?
问题
我想在我的React应用中将localhost更改为自定义域名。我已经在我的host文件中使用自定义域名进行了编辑,并且在我的package.json中设置了homepage:"http://domainname.com"。但在运行npm run build和npm start之后,它仍然在localhost上运行,项目在运行,但没有使用我的自定义域名。
英文:
I want to change localhost to custom domain name in my react app.I have edited my hostfile with custom domain name and my package.json as homepage:"http://domainname.com"/. But after npm run build and npm start, it still runs on localhost, the project runs but without my custom domain name.
答案1
得分: 2
将你的React应用托管在像Netlify或Github Pages这样的托管提供商上,并在那里更改你的域名。
React开发服务器只会在本地主机上运行。
英文:
Host your react app in a hosting provider like Netlify or Github pages and change your domain there.
React development server will only run on localhost
答案2
得分: 1
你不能在公共域上运行开发服务器。有许多方法可以构建和部署您的应用程序到生产环境。这将使其从任何地方可访问。问题在于您的计算机无法在域上托管服务器,而不是在本地主机上。您可以使用不同的托管提供商,如Netlify、Heroku、Firebase Hosting或GitHub Pages。
英文:
You cannot run a development server in a public domain. There are many ways you could build and deploy your app to production. This will make it available from anywhere. The thing is that your computer can't host the server on the domain rather than localhost. You can use different hosting providers like Netlify, Heroku, Firebase Hosting or GitHub Pages.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论