我应该使用什么而不是本地主机来部署React应用程序?

发布于 2025-02-09 03:31:59 字数 609 浏览 2 评论 0原文

请,我在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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

幼儿园老大 2025-02-16 03:31:59

无论您在端口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.

绮筵 2025-02-16 03:31:59

您是否将主页道具添加到poffage.json文件中?

have you added the homepage props into the package.json file.?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文