Answer the question
In order to leave comments, you need to log in
Why doesn't app.get('/') work while other routes work?
Good evening. A very strange situation, please help. I go to the domain, but there is no callback from the get handler, and all other routes work like clockwork.. Including post request for '/' . Please help.
const { app,static } = require('../modules/app_config')
const { passport } = require('../modules/packages')
const { pass } = require('../modules/passport')
app.get('/', (req, res) => {
return res.redirect('/admin')
})
// app.get('/authenticate', (req, res) => {
// return res.redirect('/admin')
// console.log(123)
// console.log(req.user + ' - id')
// if(req.user) res.redirect('/admin')
// else res.sendFile(`${static}/index.html`)
// })
app.post('/', (req, res, next) => {
passport.authenticate('local', function(err, user) {
if (err) {
return next(err)
}
if (!user) {
return res.redirect('/')
}
req.logIn(user, function(err) {
if (err) {
return next(err)
}
return res.redirect('/admin')
})
})(req, res, next)
})
Answer the question
In order to leave comments, you need to log in
I ran into the same problem - I searched a lot in various forums, as a result - I came to the simple conclusion that the callback for switching to "" or "/" is simply not called. Please use another link.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question