🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

csp-header-middleware

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

csp-header-middleware

Middleware for express app for adding Content-Security-Policy header

1.0.0
latest
npm
Version published
Maintainers
1
Created
Source

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

Keywords

csp

FAQs

Package last updated on 12 Jun 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts