Answer the question
In order to leave comments, you need to log in
Why doesn't it redirect when registering in node.js?
Good afternoon everyone, please tell me why I am not being redirected to the page specified in the code upon successful registration? I am registering using passport.js + sequelize(postgressql), in the code below (router), when the user enters data, a redirect should work, the passport.js code is written correctly, since the data is added to the table during registration, but at the same time, everyone I am not being redirected to the specified index page, it says that the page is unavailable after some time, why? the page exists, and if you don’t make a registration request, but just start the server and go to /index, then everything is displayed well, but when the registration request comes in and the data is added to the database, then all the pages seem to die off, I can’t go anywhere until I restart the server
const passport = require('passport');
const { Router } = require('express');
const router = new Router();
router.get('/signup', (req, res) => {
res.render('signup');
});
router.get('/index', (req, res) => {
res.render('index');
});
router.post('/signup', passport.authenticate('signup', {
successRedirect: '/index', //из passport.use берется signup
failureRedirect: '/signup',
failureFlash: true
}));
module.exports = router;
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question