He escrito el código para comprobar si existe un usuario o no. En base a eso, estamos redirigiendo usando res.redirect .
app.post('/UserRegister', async (req, res, next) => { const { username, password } = req.body; const isTheir = await User.exists({ username: username}); console.log(isTheir); if (isTheir==true) { return next(new AppError("User Already Registered", 501)); } const user = new User({username}); const registeredUser = await User.register(user, password); console.log("Going to Search Flights"); res.redirect('/searchFlights'); });Parece que res.redirect no funciona ya que no va a searchFlights . Por favor ayuda .