Slide 49
Slide 49 text
CSRF protection
● Only for endpoints that will
be hit by our own frontend.
● Do not implement on
endpoints where external
clients with POST (eg. the
API)
© 2018 Coding Blocks, Arnav Gupta
const csurf = require('csurf')
app.use(csurf({cookie: true}))
app.get('/form', (req, res) => res.render('form', {
_csrf: req.csrfToken()
}))
app.post('/submit', (req, res) => {
// process data
})