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

Popular posts from this blog

PySide and Qt Properties: Connecting signals from Python to QML -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

scala - 'wrong top statement declaration' when using slick in IntelliJ -