<commit_before>import helmet from 'helmet';

let trusted = [
  "'self'"
];

const host = process.env.HOST || 'localhost';
const port = process.env.PORT || process.env.SYNC_PORT || '3000';

if (process.env.NODE_ENV !== 'production') {
  trusted = trusted.concat([
    `ws://${host}:${port}`
  ]);
}

export default function csp() {
  return helmet.contentSecurityPolicy({
    directives: {
      defaultSrc: trusted.concat([
        'https://*.cloudflare.com',
        '*.cloudflare.com',
        'https://*.optimizely.com'
      ]),<commit_msg>fix(csp): ws connection during dev uses SYNC_PORT only (#14483)<commit_after>import helmet from 'helmet';

let trusted = [
  "'self'"
];

const host = process.env.HOST || 'localhost';
const port = process.env.SYNC_PORT || '3000';

if (process.env.NODE_ENV !== 'production') {
  trusted = trusted.concat([
    `ws://${host}:${port}`
  ]);
}

export default function csp() {
  return helmet.contentSecurityPolicy({
    directives: {
      defaultSrc: trusted.concat([
        'https://*.cloudflare.com',
        '*.cloudflare.com',
        'https://*.optimizely.com'
      ]),
{'fraction_non_alphanumeric': 0.18425760286225404, 'fraction_numerical': 0.011627906976744186, 'mean_word_length': 3.2873563218390807, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4521540', 'n_tokens_mistral': 372, 'n_tokens_neox': 359, 'n_words': 75}