2013-01-02 19 views

回答

3

最簡單,最快的方法是把你靜態文件中間件領先你的「所有」的中間件:

app.use(express.static(STATIC_DIR_HERE)); 
app.use(function notStatic(req, res, next) { 
    // everything here will be non-static routes 
}); 

(其中app是您的Express實例)