Nodejs文件夹加载前端特定文件夹的路径

时间:2018-05-07 07:57:06

标签: node.js path angular5 mean-stack

我想加载www.xyz.com/frontend,我在前端文件夹中有angular4的所有前端代码。那么,我怎么能访问它。我在app.js需要什么样的改变? 有什么建议吗?

1 个答案:

答案 0 :(得分:0)

为您的角度应用设置Get路由返回index.html

 // return index html
 const path = require('path');
 app.get("/frontend", (req, res) => {
   res.sendFile(path.resolve(__dirname, 'frontend', 'index.html'));
 });