Redirect after Basic Http Auth Express.js

I want to make a private access to an application using express.js like .htaccess and .htpasswd do in my php project.

I'm using http-auth

Here is my code :

app.get('/', function(req, res) {
  basic.apply(req, res, function(username) {
    res.redirect(routes.index);
  });
});

The problem is I get an error :

500 TypeError: Object function (req, res){ res.render('index', { title: 'Express' }); } has no method 'indexOf'

Without authentication,

app.get('/', routes.index);

works without any troubles.

I think about a middleware to read my index and then use res.send()... May it works? or what did I miss?

thanks for help,

NimS

I think the argument to res.redirect needs to be a URL string, right ? You seem to be passing in a request handler (function (req, res) {...}).