From fe73399d4b5dc19299d094790cafd05af60ed4af Mon Sep 17 00:00:00 2001 From: Kimmo Puputti Date: Thu, 18 Jan 2018 14:42:24 +0200 Subject: [PATCH] If enabled, add Sentry API to the CSP whitelist --- server/csp.js | 5 +++++ 1 file changed, 5 insertions(+) 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.