1

I have a 2 routes, the first for an API and the second is a catch all which shows an html page. Now, even if I make a request to .../api/... via a browser, and see the "Invalid" - the second route, ie "called unnecessarily" still gets executed. I'm confused as to why the second route is called since it's already gone via the first route.

// api route
app.get("/api/appname/stuff_settings/:setting", function(req, res) {
   // do api stuff
   res.send(500, 'Invalid');
});

app.engine('.html', require('ejs').__express);
app.set('views', __dirname + '/views');
app.set('view engine', 'html');

// catch all route
app.use(express.static(path.join(__dirname, 'public')));
app.get('*', function(req, res){
    res.render('index', {
      console.log("called unnecessarily");
    });
});
4

1 回答 1

0

抓紧所有console.log(req.url);路线,我的钱在 favicon.ico 上。

于 2013-08-09T18:26:33.100 回答