简体   繁体   English

React:应用程序在 localhost:3000/some/path 上运行

[英]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.

相关问题 React 应用程序在 localhost:3000 上显示空白页面,但在 localhost:3001 上工作 - React app is showing blank page on localhost:3000 but working on localhost:3001 流星应用崩溃localhost:3000 - Meteor app crashing localhost:3000 React fetch('http:// localhost:3000 / profile /:id') - React fetch('http://localhost:3000/profile/:id') React.js / Firebase 应用程序中的 Axios 错误(404):POST http://localhost:3000/login 404(未找到) - Axios error (404) in React.js / Firebase app: POST http://localhost:3000/login 404 (Not Found) 当 react 应用程序未在 localhost:3000 上加载时,如何设置 webpack 和 babel - How do I set up webpack and babel when react app is not loading on localhost:3000 React app Not Working on localhost:3000 即使它以零错误编译并显示在 localhost 的标题上,也不显示任何内容 - React app Not Working on localhost:3000 even it is compiling with zero error and displays on title on localhost , doesn't display any content 我的 React 应用程序从不加载 localhost:3000 它只是一直在旋转(认为 React-Router-Dom 是问题所在) - My React App never loads in localhost:3000 its just always spinning (Think React-Router-Dom is the issue) 将应用程序部署到 Heroku 会引发错误 { path=“/” path=“/favicon.ico” }。 但在本地主机上运行 - Deploying app to Heroku throws error { path=“/” path=“/favicon.ico” }. But runs on localhost reactjs.env 将 localhost:3000 添加到我的 axios 路径 - reactjs .env add localhost:3000 to my axios path 原点 http://localhost:3000 已被 CORS 政策阻止:我的反应应用程序中的 Access-Control-Allow-Origin - origin http://localhost:3000 has been blocked by CORS policy: The Access-Control-Allow-Origin In my react App
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM