[英]React: App runs on localhost:3000/some/path
I created a fresh React app using create-react-app
and pushed it to my repo.我使用
create-react-app
创建了一个新的 React 应用程序并将其推送到我的仓库。
I have also setup the pipeline and deployed it to a server for testing and it works fine.我还设置了管道并将其部署到服务器进行测试,它工作正常。
However, when I run it on local, my app run on the following location:但是,当我在本地运行它时,我的应用程序在以下位置运行:
localhost:3000/my-user-name/app-name
How do I make it run on localhost:3000
only如何使其仅在
localhost:3000
上运行
I faced this issue recently.我最近遇到了这个问题。
Check if you have homepage
inside your package.json
.检查您的
package.json
中是否有homepage
。
If the homepage url contains any path ahead of the domain, it will pick that and use it with the localhost
.如果主页 url 包含域前面的任何路径,它将选择该路径并将其与
localhost
一起使用。
If you want to run the app on localhost:3000
only, then you can consider modifying the homepage url or removing it, if possible.如果您只想在
localhost:3000
上运行应用程序,那么您可以考虑修改主页 url 或删除它,如果可能的话。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.