Friday, 12 May 2017

expressjs / nodejs general routes conflicting with wildcard

In my app, one can access /someusername

I have that route defined as

app.get('/:username', function(req, res) {

but because I also have these general ones like /stats and /login

app.get('/stats', function(req, res) {})
app.get('login',  function(req, res) {})

going to these also accesses the /:username route.

how do I prevent that?

(the /:username route is the last one in the code)



via totalnoob

No comments:

Post a Comment