使用connect-mongo报这个错 Cannot read property 'length' of undefined,怎么办
发布于 9 年前 作者 Hokkaidosunny 3707 次浏览 最后一次编辑是 8 年前 来自 问答

var session = require(“express-session”); var MongoStore = require(‘connect-mongo’)(session);

var app = express();

app.set(‘views’, path.join(__dirname, ‘views’)); app.set(‘view engine’, ‘ejs’);

app.use(logger(‘dev’)); app.use(bodyParser.json()); app.use(bodyParser.urlencoded({ extended: false })); app.use(cookieParser()); app.use(express.static(path.join(__dirname, ‘public’)));

app.use(session({ secret:settings.cookieSecret, key:settings.db, cookie:{maxAge:100060602430}, store:new MongoStore({ db:settings.db, host:settings.host, port:settings.port }), resave: true, saveUninitialized: true }));

回到顶部