angular 中的路由和 nodejs 部署的应用程序无法正常工作

routes in angular and nodejs deployed app not working

我已经在 heroku 上部署了一个 nodejs 和 angular 应用程序,但是部署后的路由不起作用。 这是我的网站 - https://murti123.herokuapp.com 有路线 - enter link description here

但是对于路由,它给出了 can't get / 错误。 我不知道怎么解决

Here is My project Structureenter code here

您需要resolve您的前端应用程序路径

所以假设在 /public 文件夹中你有来自构建的前端应用程序的 dist 文件

app.use(express.static(__dirname + "/public"));

在这里你为任何路线解决 index.html

app.get("*", function (req, res) {
  //path is required at the top of the file ofcourse
  //const path = require("path"); 
  res.status(200).sendFile(path.resolve(__dirname + "/public/index.html"));
});