javascript – Saving login / password in browser after redirect in expressjs?


Tell me how to activate the window for saving the login / password in the browser, if after this very login I have a redirect.

PS> If you replace the redirect with res.send, then everything works, but how then to return the user to the previous page?

app.put('/login', function(req, res, next) {
  pool.query('SELECT idperson, nickname, email, password FROM person WHERE email=? AND password=?', [, req.body.password], function(err, rows, fields, next) {
    if (err) return next(err);
    if (!rows[0]) console.log('Неверные данные');
    else {
      req.session.idperson = rows[0].idperson;
      req.session.nickname = rows[0].nickname;

HTML with templating (pug)

 form(method="post" action="/login" enctype="application/x-www-form-urlencoded") input(type="email" placeholder="введите email" name="email" required) input(type="password" placeholder="введите пароль" name="password" pattern="[A-Za-z0-9]{6,30}" title="Пароль может содержать только латинские буквы(az) и цифры(0-9), от 6 до 30 символов." required) input(type="hidden" name="_method" value="PUT") input(type="submit" name="login" value="Войти")


Saving the password, oddly enough, happens only in the case of res.send 🙁

Total working code:

			form(id="test" method="post" action="/login") 
					input(type="email" required)
					input(type="password" required)
					input(type="submit"  value="субмит")'/login', function(req, res, next) {
  var backurl="Возвращаемся назад <script>window.location = '"+req.header('Referer')+"';</script>";
Scroll to Top