【问题标题】:Nodejs Folder Path to load particular folder for frontend为前端加载特定文件夹的Nodejs文件夹路径
【发布时间】:2018-10-16 23:37:32
【问题描述】:

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

【问题讨论】:

    标签: node.js path angular5 mean-stack


    【解决方案1】:

    为您的 Angular 应用设置返回 index.htmlGet 路由。

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

    【讨论】:

    • 无法获取 /frontend
    • 你能分享你所做的改变吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-02-01
    • 2014-03-13
    • 2012-01-27
    • 1970-01-01
    • 2018-09-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多