Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我的默认路由器是:
app.get('/', function (req, res) { console.log("default"); res.send("ok"); });
index.html如果我的静态目录中没有 a ,则logandsend将按原样输出,
index.html
log
send
但是当我添加时index.html,路由器会直接跳转到页面,然后我将名称更改index为另一个名称,它不会再次跳转。
index
为什么会这样?如何更改此设置?
导致此行为的是您的中间件顺序和配置。您可能正在使用static中间件,并且默认情况下发生在app.router中间件之前。解决方案是:
static
app.router
app.user(app.router);