hc-mid-csp
v1.1.13
Published
[hc-bee](https://github.com/node-honeycomb/hc-bee) middleware to add csp headers
Readme
hc-mid-csp
hc-bee middleware to add csp headers
install
npm i -S hc-mid-cspusage
config options see helmet-csp, with below different:
- add
cspStringoption to allow setCSPcontent directly, if empty, fallback todirectives - add
acceptsoption to only apply headers according to req.accepts, default istext/html directivesalso allowstringtype value, to prevent merge config ofhc-bee${prefix}and${nonce}can be put into string as placeholderdirectives.reportUridefault value:${prefix}/__csp__res.locals.cspNoncecontains thenoncevalue- add
x-csp-nonceheaders
example
middlewareConfig = {
csp: {
enable: true,
module: './csp',
config: {
reportOnly: true,
cspString: ``,
directives: {
"defaultSrc": "'none'",
"baseUri": "'none'",
"blockAllMixedContent": true,
"connectSrc": "'self' g.alicdn.com",
"fontSrc": "'self' data: at.alicdn.com g.alicdn.com",
"formAction": "'self'",
"frameAncestors": "'none'",
"frameSrc": "'self' g.alicdn.com",
"imgSrc": "'self' data: img.alicdn.com",
"objectSrc": "'none'",
"manifestSrc": "'self'",
"mediaSrc": "'none'",
"scriptSrc": "'report-sample' 'nonce-${nonce}' 'unsafe-inline' 'self' s.tianchi.aliyun.com"
}
}
}
}