Skip to content

Commit

Permalink
Add missing Content Security Policy (CSP)
Browse files Browse the repository at this point in the history
  • Loading branch information
caleb531 committed Dec 25, 2021
1 parent cda0409 commit 5516f7d
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion app/server/express-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,23 @@ if (process.env.NODE_ENV === 'production') {
app.enable('trust proxy');
app.use(expressEnforcesSSL());
}
app.use(helmet());
app.use(helmet({
contentSecurityPolicy: {
useDefaults: true,
directives: {
/* eslint-disable quotes */
'default-src': ["'none'"],
'style-src': ["'self'"],
'img-src': ["'self'"],
'font-src': ["'self'", 'https://*.gstatic.com', 'data:'],
'script-src': ["'self'", "'unsafe-inline'", 'https://storage.googleapis.com', 'https://www.google-analytics.com'],
'child-src': ["'self'"],
'connect-src': ["'self'"],
'manifest-src': ["'self'"]
/* eslint-enable quotes */
}
}
}));

// Serve assets using gzip compression
app.use(compression());
Expand Down

1 comment on commit 5516f7d

@vercel
Copy link

@vercel vercel bot commented on 5516f7d Dec 25, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.