1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-10-18 20:09:08 +02:00
unleash.unleash/lib/middleware/secure-headers.js

36 lines
1.0 KiB
JavaScript
Raw Normal View History

const helmet = require('helmet');
module.exports = function(config) {
2020-10-01 21:47:40 +02:00
if (config.secureHeaders) {
return helmet({
2020-09-18 11:30:30 +02:00
hsts: {
maxAge: 63072000,
includeSubDomains: true,
preload: true,
},
contentSecurityPolicy: {
directives: {
2020-10-01 21:47:40 +02:00
defaultSrc: ["'self'"],
fontSrc: [
"'self'",
'fonts.googleapis.com',
'fonts.gstatic.com',
],
styleSrc: [
"'self'",
2020-09-07 09:51:30 +02:00
"'unsafe-inline'",
'fonts.googleapis.com',
'fonts.gstatic.com',
'data:',
],
2020-10-01 21:47:40 +02:00
scriptSrc: ["'self'"],
imgSrc: ["'self'", 'data:', 'gravatar.com'],
},
},
});
}
return (req, res, next) => {
next();
};
};