Проблема с получением доступа к MongoDB Atlas после развертывания - PullRequest
0 голосов
/ 11 марта 2020

Я просто внедряю приложение MERN-стека в Heroku, подключаю его к MongoDB Atlas, и все работает локально (вход, вход, добавление, удаление), но когда в Heroku не работает (я использовал строку MongoDB Atlas) , но это не работает. Может кто-нибудь помочь мне?

сервер. js:

// SignUp
app.post("/account/users/signUp", (req, res) => {
  SignUp.signUp(req, res);
});
// Login
app.post("/account/users/login", (req, res) => {
  login.login(req, res);
});
// wishList
app.post("/account/users/favorites", (req, res) => {
  addFavorites.addFavorites(req, res);
});
//Get
app.get("/account/users/favoritesList/:id", (req, res) => {
  getFavorite.getFavorite(req, res);
});
//Get onWishList
app.get("/account/users/onWishList/:id", (req, res) => {
  onWishList.onWishList(req, res);
});
//handleDelete
app.delete("/account/users/favoritesList/:userId/:movieId", (req, res) => {
  handleDelete.handleDelete(req, res);
});


// Serve The react app
app.get('*', (req, res) => {
  res.sendFile(path.join(__dirname + '/client/build/index.html'));
});

// Serve Static Assets if in Production
if (process.env.NODE_ENV == "production" || true) {
  const root = path.join(__dirname, 'client', 'build')
  app.use(express.static(root));
  app.get("*", (req, res) => {
    res.sendFile('index.html', { root });
  })

}
// Port
// const port = process.env.PORT || 5000;
// app.listen(port, () => console.log(`Listening on port ${port}...`));

let server = app.listen(process.env.PORT || 5000, function () {
  let port = server.address().port;
  console.log("Express is working on port " + port);
});

возможно я что-то не так сделал?

...