Node.js windows 10上的Redis与Express

Node.js windows 10上的Redis与Express,node.js,windows,express,redis,passport.js,Node.js,Windows,Express,Redis,Passport.js,我想在带有Express和Passport的windows上使用Redis。但当我提出任何请求时,我得到了以下错误: Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client at ServerResponse.setHeader (_http_outgoing.js:526:11) at ServerResponse.header (C:\Users\alpaga\Do

我想在带有Express和Passport的windows上使用Redis。但当我提出任何请求时,我得到了以下错误:

Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
    at ServerResponse.setHeader (_http_outgoing.js:526:11)
    at ServerResponse.header (C:\Users\alpaga\Documents\Documents\Programmation\Express-Passport-Redis\Main\node_modules\express\lib\response.js:767:10)
    at ServerResponse.send (C:\Users\alpaga\Documents\Documents\Programmation\Express-Passport-Redis\Main\node_modules\express\lib\response.js:170:12)
    at done (C:\Users\alpaga\Documents\Documents\Programmation\Express-Passport-Redis\Main\node_modules\express\lib\response.js:1004:10)
    at Object.exports.renderFile (C:\Users\alpaga\Documents\Documents\Programmation\Express-Passport-Redis\Main\node_modules\pug\lib\index.js:412:12)
    at View.exports.__express [as engine] (C:\Users\alpaga\Documents\Documents\Programmation\Express-Passport-Redis\Main\node_modules\pug\lib\index.js:455:11)
    at View.render (C:\Users\alpaga\Documents\Documents\Programmation\Express-Passport-Redis\Main\node_modules\express\lib\view.js:135:8)
    at tryRender (C:\Users\alpaga\Documents\Documents\Programmation\Express-Passport-Redis\Main\node_modules\express\lib\application.js:640:10)
    at Function.render (C:\Users\alpaga\Documents\Documents\Programmation\Express-Passport-Redis\Main\node_modules\express\lib\application.js:592:3)
    at ServerResponse.render (C:\Users\alpaga\Documents\Documents\Programmation\Express-Passport-Redis\Main\node_modules\express\lib\response.js:1008:7)
当我在Linux上用相同的代码使用Redis时,我没有这个错误(我的会话不是保存在Windows上的Redis中,而是在Linux上)

其他问题是,我可以在Linux上登录并保存会话,但当我使用passport检查身份验证时,函数返回值始终为false

var createError = require('http-errors');
var express = require('express');
const session = require('express-session');
var path = require('path');
var cookieParser = require('cookie-parser');
var logger = require('morgan');
const redis = require('redis');
const redisClient = redis.createClient({
  host: 'localhost',
  port: 6379
});
const redisStore = require('connect-redis')(session);
const passport = require('passport');
const LocalStrategy = require('passport-local').Strategy;

var app = express();

redisClient.on('error', (err) => {
  console.log('Redis error: ', err);
});

// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'pug');

app.use(logger('dev'));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser('hey You'));
app.use(express.static(path.join(__dirname, 'public')));

app.use(passport.initialize());
app.use(passport.session());
app.use(session({
  secret: 'hey You',
  resave: false,
  saveUninitialized: true,
  cookie: {secure: true, maxAge:86400000},
  store: new redisStore({client: redisClient}),
}));


app.get('/success', (req, res) => res.render('index', { title: 'OK' }));
app.get('/failure', (req, res) => res.render('index', { title: 'KO' }));
app.post('/login', passport.authenticate('local', {
  successRedirect: '/success',
  failureRedirect: '/failure',
  failureFlash: true
}));

app.get('/connected', (req, res, next) => {
  console.log(req.session);
  if (req.isAuthenticated()) {
    return res.render('index', { title: 'Connected' });
  }
  return res.render('index', { title: 'Not Connected' })
});

passport.use(new LocalStrategy({usernameField: 'email'}, 
    async (email, password, done) => {
      return done(null, {id: 1, email: 'eliott.martin@epitech.eu'});
    }
));
passport.serializeUser((user, done) => {
  console.log(user);
  return done(null, user.id)
});
passport.deserializeUser((id, done) => {
  console.log(id);
  return done(null, {id: 1, email: 'eliott.martin@epitech.eu'});
});

// catch 404 and forward to error handler
app.use(function(req, res, next) {
  next(createError(404));
});


// error handler
app.use(function(err, req, res, next) {
  // set locals, only providing error in development
  res.locals.message = err.message;
  res.locals.error = req.app.get('env') === 'development' ? err : {};

  // render the error page
  res.status(err.status || 500);
  res.render('error');
});

module.exports = app;
如果有人知道如何修复它

谢谢