showing results for - "csurf in express"
Caterina
30 Aug 2017
1var bodyParser = require('body-parser')
2var cookieParser = require('cookie-parser')
3var csrf = require('csurf')
4var express = require('express')
5
6var app = express()
7app.use(bodyParser.urlencoded({ extended: false }))
8app.use(cookieParser())
9app.use(csrf({ cookie: true }))
10
11// error handler
12app.use(function (err, req, res, next) {
13  if (err.code !== 'EBADCSRFTOKEN') return next(err)
14
15  // handle CSRF token errors here
16  res.status(403)
17  res.send('form tampered with')
18})
19
Luana
24 Jun 2018
1$ npm install csurf
2
Maissa
20 Oct 2017
1var csurf = require('csurf')
2