使用connect-mongo报这个错 Cannot read property 'length' of undefined,怎么办
发布于 16小时前 作者 Hokkaidosunny 39 次浏览 来自 问答

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 }));

回到顶部