1.0.0 • Published 3 years ago
csp-header-middleware v1.0.0
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
License
1.0.0
3 years ago