Answers for "csurf in express"

0

csurf in express

var bodyParser = require('body-parser')
var cookieParser = require('cookie-parser')
var csrf = require('csurf')
var express = require('express')

var app = express()
app.use(bodyParser.urlencoded({ extended: false }))
app.use(cookieParser())
app.use(csrf({ cookie: true }))

// error handler
app.use(function (err, req, res, next) {
  if (err.code !== 'EBADCSRFTOKEN') return next(err)

  // handle CSRF token errors here
  res.status(403)
  res.send('form tampered with')
})
Posted by: Guest on January-17-2021
0

csurf in express

$ npm install csurf
Posted by: Guest on January-17-2021
0

csurf in express

var csurf = require('csurf')
Posted by: Guest on January-17-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language