node.js - Change URL after POST using ExpressJS -
i use expressjs nodejs server. user sends me login info through post , after checking credentials render page:
router.post("/login", function (req: request, res: response, next) { if(credentialsok){ res.render('main'); } });
the problem url becomes http://myaddress/login , remove /login of address. don't want use redirect want send local variables through render.
how can change url?
you can still pass local variables through res.redirect
.
router.post("/login", function (req: request, res: response, next) { if(credentialsok){ req.session.localvar = yourlocalvar; res.redirect('/main'); }
});
then in main
router:
router.get("/main", function (req: request, res: response, next) { var yourlocalvar = req.session.localvar; res.render('main'); });
Comments
Post a Comment