Created
December 31, 2012 22:41
-
-
Save boutell/4423489 to your computer and use it in GitHub Desktop.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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