If enabled, add Sentry API to the CSP whitelist

This commit is contained in:
Kimmo Puputti 2018-01-18 14:42:24 +02:00
parent 57d504d18a
commit fe73399d4b

View file

@ -3,6 +3,7 @@ const { config } = require('./importer');
const dev = process.env.REACT_APP_ENV === 'development';
const googleAnalyticsEnabled = !!process.env.REACT_APP_GOOGLE_ANALYTICS_ID;
const sentryClientEnabled = !!process.env.REACT_APP_PUBLIC_SENTRY_DSN;
/**
* Middleware for creating a Content Security Policy
@ -32,6 +33,7 @@ module.exports = (reportUri, enforceSsl, reportOnly) => {
const googleFonts = 'https://fonts.googleapis.com/';
const stripeJs = 'https://js.stripe.com/';
const stripeQ = 'https://q.stripe.com/';
const sentryApi = 'https://sentry.io/api/';
const scriptSrc = [self, inline, googleMaps, stripeJs];
@ -61,6 +63,9 @@ module.exports = (reportUri, enforceSsl, reportOnly) => {
scriptSrc.push(googleAnalytics);
imgSrc.push(googleAnalytics);
}
if (sentryClientEnabled) {
connectSrc.push(sentryApi);
}
if (dev) {
// The default Core docker-compose setup server images from this
// URL locally.