gpt4 book ai didi

express - 类型错误 : Cannot read property '_csrf' of undefined

转载 作者:行者123 更新时间:2023-12-04 17:36:23 25 4
gpt4 key购买 nike

我收到 CSRF token 错误..
TypeError: Cannot read property '_csrf' of undefined at Object.handle (/home/nodejs/sites/IcoderStuff/node_modules/express/node_modules/connect/lib/middleware/csrf.js:45:28) at next (/home/nodejs/sites/IcoderStuff/node_modules/express/node_modules/connect/lib/proto.js:190:15) at Object.session [as handle] (/home/nodejs/sites/IcoderStuff/node_modules/express/node_modules/connect/lib/middleware/session.js:221:66) at next (/home/nodejs/sites/IcoderStuff/node_modules/express/node_modules/connect/lib/proto.js:190:15) at Object.cookieParser [as handle] (/home/nodejs/sites/IcoderStuff/node_modules/express/node_modules/connect/lib/middleware/cookieParser.js:60:5) at next (/home/nodejs/sites/IcoderStuff/node_modules/express/node_modules/connect/lib/proto.js:190:15) at Object.methodOverride [as handle] (/home/nodejs/sites/IcoderStuff/node_modules/express/node_modules/connect/lib/middleware/methodOverride.js:37:5) at next (/home/nodejs/sites/IcoderStuff/node_modules/express/node_modules/connect/lib/proto.js:190:15) at Object.expressValidator [as handle] (/home/nodejs/sites/IcoderStuff/node_modules/express-validator/lib/express_validator.js:148:10) at next (/home/nodejs/sites/IcoderStuff/node_modules/express/node_modules/connect/lib/proto.js:190:15)
包 (packages.json)

"express": "3.0.3",
"less-middleware": "0.1.12",
"hbs": "2.3.0",
"express-validator": "0.4.1",
"mongoose" : "3.x",
"node-uuid" : "1.x",
"request" : "2.x",
"async" : "0.2.x",
"date-utils": "1.x",
"jade": "0.31.2",
"xml2js" : "0.2.7",
"MD5" : "1.0.3",
"csv" : "0.3.3",
"nodemailer" : "0.4.4"

服务器.js
app.configure(function(){
app.set('port', process.env.PORT || 8080);
app.set('views', __dirname);
app.set('view engine', 'html');
app.engine('html', require('hbs').__express);
app.use(express.favicon());
app.use(express.logger('dev'));
app.use(express.bodyParser());
app.use(expressValidator);
app.use(express.methodOverride());
app.use(express.cookieParser());
app.use(express.session({ secret: 'xkvnjiersape', store: store }));
app.use(express.csrf());
app.use(express.static(path.join(__dirname, 'public')));
app.use(require('less-middleware')({ src: __dirname + '/public' }));
app.use(require('grunt-contrib-livereload/lib/utils').livereloadSnippet);
app.use(app.router);
});

最佳答案

也许这会对其他人有所帮助,不确定这对我来说是否与 OP 的原因相同。但是,在重新启动计算机后,这个问题出现在我身上,经过很长时间的尴尬,我发现这是因为 Redis(我使用 connect-redis 作为 session 存储)没有自动重新启动。

换句话说,似乎TypeError: Cannot read property '_csrfSecret' of undefinedcsrf of undefined当 session 存储不可用时发生。

关于express - 类型错误 : Cannot read property '_csrf' of undefined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17596228/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com