Express.js Handle unmached routes
问题 Fellows I develop a Rest API and I want when a route does not exist to send a custom message instead of an html one that express.js sends by default. As fas as I searched I could not find a way to do that. I tried to do: app.all("*",function(req,res){ res.status(404) res.header("Content Type","application/json") res.end(JSON.stringify({message:"Route not found"})) }); But it matches and all already implemented methods. I want only the unmached one to get handled by my app. Edit 1 For each