[英]why doesn't app.get middleware works after app.use middleware in expressjs
I am using the following code in my server.js file, but the code in get is never running with app.use() middleware but once I comment out the app.use middleware, app.get() middleware is functioning properly. 我在server.js文件中使用了以下代码,但是get中的代码从未与app.use()中间件一起运行,但是一旦我注释掉了app.use中间件,app.get()中间件就可以正常工作。 Can someone tell me why this is happening? 有人可以告诉我为什么会这样吗? Here is a snippet of my code- 这是我的代码的片段-
app.use('/',express.static('public'))
app.get('/',(req,res)=>{
console.log('get req on /')
res.send('returned') })
尝试app.use('/', express.static('public', {fallthrough: true}))
编辑:没关系,看起来像fallthrough是默认设置,因此指定此选项不会改变行为。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.