我有' /'的处理程序,重定向到/login.html
。
但是,即使我明确地调用重定向,呈现的页面仍然是STILL index.html。
var app = express();
app.use(express.static('public'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: false}));
app.use(cookieParser());
app.use(session({ secret: 'keyboard cat', resave: false, saveUninitialized: false }));
app.use(passport.initialize());
app.use(passport.session());
MW:
app.use('/', (req, res, next) => {
if (req.user) {
next();
} else {
res.redirect('/login.html');
}
});
app.post('/login',
passport.authenticate('local', {
successRedirect: '/index.html',
failureRedirect: '/login.html'
})
);