javascript - How to retrieve form data sent over HTTPS in node? -


i'm bit of back-end security n00b, please gentle if i'm missing obvious:

when values on http in node, form data in request object req.body.{name of input element}

over https, req.body doesn't seem exist. i've tried logging out req object can't see anywhere in there. doing wrong?

function checkuser(req, res) {     console.dir(req);     //if passwords don't match     if (req.body.password !== req.body.confirm_password) {         return false;     }     return true; }  app.post('/register', function(req, res) {      if (checkuser(req, res)) {         createuser(req, res)         res.redirect('/browse?p=0');     }     res.render('register', {         error: 'passwords did not match'     }) }); 

as goes checkuser method crashes saying req.body not defined. data kept?

any appreciated...

thanks

james

req.body exists if link in appropriate middleware parse request body. recommend following:

app.use(express.urlencoded()); app.use(express.json()); 

you see express.bodyparser() being used, recommend avoiding because includes express.multipart(), has been deprecated, , disappear when express updates dependency on connect. if need parse multipart form data, busboy or formidable.

i don't think issue has https: parsing request body same process in http , https.


Comments

Popular posts from this blog

php - SPIP: From Tag directly to an article -

jquery - isAjaxRequest always return false -

ruby on rails - In a controller spec, how to find a specific tag in the generated view? -