节点静态路由

时间:2019-07-08 08:01:54

标签: javascript node.js

我的应用程序中存在路由问题。我的文件系统看起来像

/allure-report
/allure-report/index.html
/public
/public/index.html
/start.js

我已经设置了公开的静态和静态路线

app.use(express.static('public'));

现在调用节点服务器,它将很好地发送我的html代码。

res.send(myHtmlCode);

但是如果我想在其他按钮中使用,则会崩溃:

res.sendFile(__dirname + '/allure-report/index.html');

按照我添加的文档进行操作:

app.use(express.static('public'));
app.use(express.static('allure-report'));

在文档中写道,它将按照我添加路径的方式使用搜索顺序。但是在这种情况下,应用程序将始终显示allure-report / index.html”,而不是我自己的html。这非常令人困惑。

没有诱人的静态路由,sendfile将不执行任何操作。旧页面不会更改。

0 个答案:

没有答案
相关问题