小编ath*_*shi的帖子

部署成功后,无法通过 Heroku 上的前端连接到后端

我已经在heroku 上部署了我的mern stack 应用程序。问题是我无法向我的后端发出任何请求。我像这样将我的前端连接到我的后端......

API=http://localhost:5000/api

 import { API } from "../../backend";
import { signin } from "../../auth/helper";
export const getAllProducts = () => {
  return fetch(`**${API}/allProducts**`, { method: "GET" })
    .then((response) => {
      return response.json();
    })
    .catch((err) => {
      console.log(err);
    });
};
Run Code Online (Sandbox Code Playgroud)

我想我正在本地主机上调用 api,这就是为什么我没有连接到后端。我应该在这里做什么?

如果你还想要什么,可以告诉我。

heroku reactjs mern

5
推荐指数
1
解决办法
3417
查看次数

标签 统计

heroku ×1

mern ×1

reactjs ×1