Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Routes with parameters gets called twice?

I am creating a NodeJS web application via ExpressJS. I have the following two routes (among others):

app.get('/user/reset/verify', function(req, res) {
    console.log("Executing verification index.");
    res.render("verify/index");
});

app.get('/user/reset/verify/:email/:token', function(req, res) {
    console.log("Executing verification change.");
    res.render("verify/change");
});

When I go to the verification index page, I see "Executing verification index." printed once on the console. However, when I go to the verification change page, I see "Executing verification change." printed twice on the console.

I have noticed that this is a trend with the routes in my app. Routes that contain parameters are always executed twice, while routes without parameters are only (properly) executed once.

Why are the routes with parameters being executed twice?

The views that are being rendered only contain simple HTML - nothing that would cause another request to the page. Also, I am issuing these requests from a Chrome browser.

Platform/Versions:

  • NodeJS: 0.5.5 windows build (running on Win 7)
  • Express: 2.4.6
  • Connect: 1.7.1
like image 377
Stephen Watkins Avatar asked Sep 20 '11 01:09

Stephen Watkins


1 Answers

The second request is the /favicon.ico Try to console log your request.url in your http_server request handler, you'll see the first is the browser url and the next the favicon.

like image 112
thierry Avatar answered Oct 09 '22 00:10

thierry