将MERN Stack应用程序部署到Azure应用服务

时间:2020-04-20 09:54:23

标签: node.js reactjs azure express

我想将我的MERN堆栈应用程序部署到Azure App Service。到现在为止,无论我遇到什么教程,它们都在同一个目录和server.js文件中都有一个客户端和服务器代码的git repo,它们正在执行此操作:

app.get("*", (req, res) => { 
  res.sendFile(path.resolve(__dirname, "client", "build", "index.html"));
});

我几乎到处都发现了相同的方法。但就我而言,我有两个不同的git repos,一个用于react应用程序,一个用于node-express应用程序。在我的server.js文件中也有以下代码:

routes.all("*", (_req: any, _res: any, next: any) =>
 next(new APIError(
   `${_req.originalUrl} is not found on this server`,HTTPStatus.NOT_FOUND,true
  )
 )
);

所以不确定如何将我的MERN应用部署到天蓝色。可以请人提供指导。

我遵循了以下两个教程:

Tutorial 1

Tutorial 2

0 个答案:

没有答案