Skip to content

Instantly share code, notes, and snippets.

@Gpx
Last active December 16, 2015 17:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Gpx/5474596 to your computer and use it in GitHub Desktop.
Save Gpx/5474596 to your computer and use it in GitHub Desktop.
Enable CSRF protection on Express
var express = require('express');
var app = express();
app.use(express.bodyParser()); // Read POST parameters
app.use(express.cookieParser()); // Read cookies
app.use(express.cookieSession({secret: 'mysecret'})); // Create a session using cookies
app.use(express.csrf()); // Enable CSRF protection
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment