heroku上的Node.js和Mongo会话错误
将我的应用程序部署到heroku时出现以下错误。我在localhost上没有任何错误。我错过了什么 GET/304 522ms GET/public/stylesheets/bootstrap.css 200 15ms- 131.2kb GET/public/stylesheets/style.css 200 3ms-799b GET/public/images/food2.jpg 200 62ms-812.2kb /app/node_modules/connect mongo/node_modules/mongodb/lib/mongodb/connection/base.js:242heroku上的Node.js和Mongo会话错误,node.js,mongodb,heroku,express,Node.js,Mongodb,Heroku,Express,将我的应用程序部署到heroku时出现以下错误。我在localhost上没有任何错误。我错过了什么 GET/304 522ms GET/public/stylesheets/bootstrap.css 200 15ms- 131.2kb GET/public/stylesheets/style.css 200 3ms-799b GET/public/images/food2.jpg 200 62ms-812.2kb /app/node_modules/connect mongo/node_mod
throw message;
^ **Error: Error setting TTL index on collection : sessions** at
/app/node_modules/connect mongo/lib/connect mongo.js:161:23 at
/app/node_modules/connect mongo/node_modules/mongodb/lib/mongodb/db.js:1404:28
在
/app/node_modules/connect mongo/node_modules/mongodb/lib/mongodb/db.js:1542:30
在
/app/node_modules/connect mongo/node_modules/mongodb/lib/mongodb/cursor.js:159:22
在
/app/node_modules/connect mongo/node_modules/mongodb/lib/mongodb/cursor.js:685:39
在光标处。关闭
/app/node_modules/connect mongo/node_modules/mongodb/lib/mongodb/cursor.js:959:5
在commandHandler
/app/node_modules/connect mongo/node_modules/mongodb/lib/mongodb/cursor.js:685:21
在
/app/node_modules/connect mongo/node_modules/mongodb/lib/mongodb/db.js:1806:9
在Server.Base上。\u callHandler
/app/node_modules/connect mongo/node_modules/mongodb/lib/mongodb/connection/base.js:442:41
在
/app/node_modules/connect mongo/node_modules/mongodb/lib/mongodb/connection/server.js:485:18
github项目是
我也尝试过这段代码,但得到了相同的错误:
app.use(session({
secret: 'asdfghjkl',
store: new MongoStore({
db: 'app27253116',
collection: 'sessions',
host: 'kahana.mongohq.com',
port: 10097
}),
cookie: {maxAge: 900000}
}));
试试这个:
store: new MongoStore({
db: 'restaurants',
collection: 'sessions',
host: 'localhost',
port: 27017,
auto_reconnect:true
}),
store: new MongoStore({
db: 'restaurants',
collection: 'sessions',
host: 'localhost',
port: 27017,
auto_reconnect:true
}),