I have an express.js app set up like this:
app.use(express.static(__dirname + '/public'));
...
app.all('*', require('./routes/all'));
So when I try to load /stylesheets/style.css
, request is dispatched to the routes
. How do I make the app first try to use "static", and then - the catch-all route?
Middleware get executed in sequential order. Simply put the static middleware before the routing middleware.
app.configure(function() {
app.use(express.static(__dirname + '/public'));
app.use(app.router);
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.