Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Nested Express apps. The "Main Wildcard" route always beats all routes in catsApp even though it is added first with app.use. I wish app.use() had the same precedence as adding a route.
// HOPED-FOR BEHAVIOR: /cats says: Cats Home
// ACTUAL BEHAVIOR: /cats says: Main Wildcard
var express = require('express');
var app = express();
app.get('/', function(req, res) {
res.send('Main Home');
})
var catsApp = express();
catsApp.get('/', function(req, res) {
res.send('Cats Home');
})
app.use('/cats', catsApp);
app.get('/*', function(req, res) {
res.send('Main Wildcard');
});
app.listen(3000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment