我应该使用什么而不是本地主机来部署React应用程序?
请,我在React应用程序中有此链接表格的代码。 它在本地工作正常,但是在我部署后,它无法正常工作。我想我有其他事情改变了本地主机,但是什么呢?
假设我的域是 https://www.something.com 。 应该使用什么而不是本地主机来部署我的React应用程序?
如果我在尝试获取资源时保留Local -Host域:NetworkError,我
错误消息。 PS。:该网站也可以很好地运行(本地和部署之后)。我在这里尝试的是收到我的获取方法的答案(对于我的联系表),该方法是行不通的。
fetch('http://localhost:5500/contact', {
method: 'POST',
headers: {
'Content-Type': 'application/json;charset=utf-8',
},
body: JSON.stringify(details),
})
Please, I have this piece of code for a Contact Form in a React APP.
It works fine locally, but after I deploy it doesn't work. I guess I have change the localhost for something else, but for what?
Let's say that my domain is https://www.something.com.
What should I use instead of localhost to deploy my React App?
Error message that I receive if I keep the localhost domain: NetworkError when attempting to fetch resource.
PS.: The website works perfectly as well (locally and after the deploy). What I am trying here is to receive an answer of my fetch method (for my contact form) that it's not working.
fetch('http://localhost:5500/contact', {
method: 'POST',
headers: {
'Content-Type': 'application/json;charset=utf-8',
},
body: JSON.stringify(details),
})
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
无论您在端口5500上运行什么服务器后端,都需要在线托管。目前,您只是主持了前端。
托管后端后,将您的提取URL更改为此。
Whatever server backend you are running on port 5500 needs to be hosted online too. At the moment you just have your frontend hosted.
Once you have your backend hosted, change your fetch URL to that instead.
您是否将主页道具添加到poffage.json文件中?
have you added the homepage props into the package.json file.?