Only matching GET and POST routes if a static file doesn't match?
Problem
I have this route:
app.get('/:a/:b/:c', routes.get);
And this Static definition:
app.use('/test', express.static(__dirname + '/test'));
Now, the problem arises when I try to access /test/a/b.js
. Since it matches both paths, routes.get
is triggered. How do I prevent this, and only route if a static resource file wouldn't be served otherwise?
Problem courtesy of: Stefan Kendall
Solution
Put app.use(express.static(__dirname + '/test'))
before app.use(app.router)
.
Middleware runs in the order defined in .configure()
.
Solution courtesy of: Ricardo Tomasi
Discussion
View additional discussion.