diff --git a/server/csp.js b/server/csp.js index 233de295..58d1d57b 100644 --- a/server/csp.js +++ b/server/csp.js @@ -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.