2017-08-07 24 views

回答

0

壞消息是:express.static中間件不調用next()

好消息:您可以定義與靜態目錄通配符的app.get,這一定是在使用express.static之前完成。

例:

app.get('/staticDir/*', (req, res, next) => { 
    console.log('[static filepath requested]'); 
    next(); 
}); 
app.use(express.static(__dirname + '/staticDir'));