express 4 , app.get with parameters don't work

241 Views Asked by At

Here is my express configuration for static files and views.

    express.static.mime.define({'Image': ['png']});

Configuration for static files.

    app.use(express.static(path.join(rootPath, 'app'))); 

Configuration for views

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

When I use route without parameters , it works fine , In browser it create app folder and script sub-folder and looks for static file in it, as configured

    app.get('/verify',  function(req, res) {
        res.render('index');
    });

But when I use route with parameters , In browser it create a verify folder and look for static file in it

   app.get('/verify/:token', function(req, res){
        res.render('index');
    });

Please help me here, I am not able to understand where I am making mistake. Why it is creating a verify folder in the browser and looks for static files in it?

1

There are 1 best solutions below

4
On
app.get('/verify/:token', function(req, res){
    res.render('index');
});

You can't use parameter like this, when you are sending the parameter from verify.jade and you have to use inside app.get, just use req.query.token .