Socket
Socket
Sign inDemoInstall

csp-header-middleware

Package Overview
Dependencies
1
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    csp-header-middleware

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


Version published
Weekly downloads
2
Maintainers
1
Install size
48.7 kB
Created
Weekly downloads
 

Readme

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

FAQs

Last updated on 12 Jun 2021

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc