Open
Description
I faced a TypeError: Cannot read property 'csrf_tokens' of undefined
error when I followed your tutorial. From my understanding it's coming from the latest version of expresse that does not include those middleware by default.
My suggested workaround
npm install csurf cookie-parser express-session
Add:
var csrf = require('csurf');
var cookieParser = require('cookie-parser');
var session = require('express-session')
app.use(cookieParser());
app.use(session({secret: 'keyboard cat'}))
app.use(csrf());
app.use(function(req, res, next) {
res.cookie('XSRF-TOKEN', req.csrfToken());
next();
});
and it should be fine 😄
Metadata
Metadata
Assignees
Labels
No labels