JSPM

express-extendcsp

3.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1205
  • Score
    100M100P100Q106696F
  • License BSD-3-Clause

Extend the Content Security Policy on the fly (for development)

Package Exports

  • express-extendcsp

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (express-extendcsp) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

express-extendcsp

NPM version Build Status Coverage Status Dependency Status

Express middleware for altering the Content-Security-Policy on the fly. Mostly useful in development when you want to make sure that your debugging and stylesheet injection techniques work, but without compromsing the CSP you're running in production.

Examples I've seen so far:

Usage

Put express-extendcsp in your middleware stack before the middleware that sets your CSP, and pass it a config object with an add key, specifying which directives to add to the Content-Security-Policy header:

require('express')()
  .use(
    require('express-extendcsp')({
      add: {
        connectSrc: 'ws://*',
        styleSrc: ['blob:', 'data:'],
      },
    })
  )
  .use((req, res, next) => {
    res.setHeader(
      'Content-Security-Policy',
      "default-src 'self'; object-src 'none'"
    );
  });

Both camelCased and snake-cased directive names are supported, and you can supply the tokens to add as either a string or an array of strings.

Releases

Changelog