i have a problem in my app that i cant resolve
first of all my app:
nodejs 0.8.14 express 3.1 passport-local 0.1
the problem is when i login in passport session the client request the page two times...
i discover that because i put a request var in the url
this in my router
exports.index=function(req,res)
{
console.log('success: '+req.url);
var sesion_usuario=validate(req.params.code_user);//if not valid return null
if(sesion_usuario){
res.render('logged',{title:'Hello'+sesion_usuario})
this in my browser
http://localhost:8000/YOGE7419
this in my app
app.get('/:code_user',routes.index);
and this is what im receiving in my prompt
success: /YOGE7419
success: /YOGE7419
DEBUG: validate error: maxlength not match
and the url transform in this
http://localhost:8000/YOGE7419#sthash.zp1bOY2d.dpbs
why is that??? whats happening between first and second request?? tnx
APP CONFIGURATION
app.configure(function()
{
app.use(express.favicon(__dirname + '/public/images/favicon.png'));
app.set('port', 8000 || process.env.PORT);
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
app.set('view options',{layout:false});
//app.use(express.logger('dev'));
app.use(express.bodyParser({uploadDir:'./public/uploads/'}));
app.use(express.cookieParser('nomatherwhatdoyoudobatman'));
app.use(express.session());
app.use(passport.initialize());
app.use(passport.session());
//app.use(express.methodOverride());
app.use(app.router);
app.use(express.static(path.join(__dirname, 'public')));
app.use(function(req, res, next){
res.render('404.jade',
{
title: "404 - Page Not Found",
showFullNav: false,
status: 404,
url: req.url
});
});
});
The first request is automatically made by the browser, which requests favicon.ico, and of course, the second request is for the URL (Your URl).
Further More Refer
http://net.tutsplus.com/tutorials/javascript-ajax/node-js-for-beginners/