csp-header-middleware
v1.0.0
Published
Middleware for express app for adding Content-Security-Policy header
Downloads
2
Maintainers
Readme
csp-header-middleware
csp-header-middleware
is a middleware to add CSP headers to response to prevent XSS attacks.
Installation
npm install csp-header-middleware
How to use ?
var express = require('express')
var bodyParser = require('body-parser')
//NOTE: Don't forget to import `.cspHeaders` from lib
var cspHeaders = require('csp-header-middleware').cspHeaders;
var app = express()
app.use(bodyParser.json())
// this should comes before any routes
app.use(cspHeaders())
app.post('/your-route', (req, res) => {
// response will be added with csp header
})
Testing & Contributing
npm install
npm test