![](/img/trans.png)
[英]Express.js: How to serve one file for the default “/” route, then use express.static for the rest?
[英]Express.js: how to make express.static have higher priority than the rest of the app?
我有一個像這樣設置的express.js應用程序:
app.use(express.static(__dirname + '/public'));
...
app.all('*', require('./routes/all'));
因此,當我嘗試加載/stylesheets/style.css
, /stylesheets/style.css
請求分派給routes
。 如何讓應用程序首先嘗試使用“靜態”,然后 - 全能路線?
中間件按順序執行。 簡單地將靜態中間件放在路由中間件之前。
app.configure(function() {
app.use(express.static(__dirname + '/public'));
app.use(app.router);
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.