csp-header-middleware

1.0.0 • Public • Published

csp-header-middleware

Build Status Coverage Status

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

MIT

Package Sidebar

Install

npm i csp-header-middleware

Weekly Downloads

2

Version

1.0.0

License

MIT

Unpacked Size

4.04 kB

Total Files

5

Last publish

Collaborators

  • prasad8mhatre