When using a nodejs express application using the NPM "Helmet" package to install protective Headers, errors occur when using fontawesome: "kit_fontawesomecom_78f8060be1.js: 2 Refused to connect to 'https://ka-f.fontawesome.com/releases/v5. 15.1 / css / free.min.css' because it violates the following Content Security Policy directive: "default-src 'self'". Note that 'connect-src' was not explicitly set, so 'default-src' is used as a fallback. " Apparently security is being violated. Is there a solution to these problems?
Solved by toggling contentSecurityPolicy: false:
  helmet({
        contentSecurityPolicy: false,
  })
);
But this is not a solution to the problem, it is ignoring it.
An example of one of the posts in full:
kit_fontawesomecom_78f8060be1.js:2 Refused to connect to 'https://ka-f.fontawesome.com/releases/v5.15.1/css/free.min.css' because it violates the following Content Security Policy directive: "default-src 'self'". Note that 'connect-src' was not explicitly set, so 'default-src' is used as a fallback.
Thank you so much! This is how it works:
app.use(
    helmet.contentSecurityPolicy({
        directives: {
            defaultSrc: ["'self'", 'https://ka-f.fontawesome.com', 'https://fonts.gstatic.com'],
            scriptSrc: ["'self'", "'unsafe-inline'", 'https://ka-f.fontawesome.com'],
            styleSrc: ["'self'","'unsafe-inline'", 'https://ka-f.fontawesome.com', 'https://fonts.googleapis.com'],
            // connectSrc: ["'self'", 'https://ka-f.fontawesome.com'],
            connectSrc: ["'self'", 'https://ka-f.fontawesome.com'],
        //    reportUri: '/report-violation',   // endpoint to get violation reports
        },
        reportOnly: false,  // true for nonblocking mode, just to see violations
        safari5: false
}));