Skip to content

Commit

Permalink
Merge branch 'master' into sam/25_01_07/remove-sentry
Browse files Browse the repository at this point in the history
  • Loading branch information
bodinsamuel authored Jan 7, 2025
2 parents 61a2ecd + b873780 commit 36c835e
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions packages/server/lib/middleware/security.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ export function securityMiddlewares(): RequestHandler[] {
hostWs.protocol = hostApi.startsWith('https') ? 'wss' : 'ws';
const reportOnly = process.env['CSP_REPORT_ONLY'];

const additionalConnectSources = [process.env['PUBLIC_KOALA_API_URL'] ? new URL(process.env['PUBLIC_KOALA_API_URL']).origin : ''];
const additionalScriptSources = [process.env['PUBLIC_KOALA_CDN_URL'] ? new URL(process.env['PUBLIC_KOALA_CDN_URL']).origin : ''];

return [
helmet.xssFilter(),
helmet.noSniff(),
Expand All @@ -24,7 +27,16 @@ export function securityMiddlewares(): RequestHandler[] {
directives: {
defaultSrc: ["'self'", hostPublic, hostApi],
childSrc: "'self'",
connectSrc: ["'self'", 'https://*.google-analytics.com', 'https://*.sentry.io', hostPublic, hostApi, hostWs.href, 'https://*.posthog.com'],
connectSrc: [
"'self'",
'https://*.google-analytics.com',
'https://*.sentry.io',
hostPublic,
hostApi,
hostWs.href,
'https://*.posthog.com',
...additionalConnectSources
],
fontSrc: ["'self'", 'https://*.googleapis.com', 'https://*.gstatic.com'],
frameSrc: ["'self'", 'https://accounts.google.com', hostPublic, hostApi, connectUrl, 'https://www.youtube.com'],
imgSrc: [
Expand All @@ -51,7 +63,8 @@ export function securityMiddlewares(): RequestHandler[] {
'https://*.googleapis.com',
'https://apis.google.com',
'https://*.posthog.com',
'https://www.youtube.com'
'https://www.youtube.com',
...additionalScriptSources
],
styleSrc: ['blob:', "'self'", "'unsafe-inline'", 'https://*.googleapis.com', hostPublic, hostApi],
workerSrc: ['blob:', "'self'", hostPublic, hostApi, 'https://*.googleapis.com', 'https://*.posthog.com']
Expand Down

0 comments on commit 36c835e

Please sign in to comment.