Express with helmet: CDN scripts, inline scripts or images blocked by Content-Security-Policy after deploying
@devsingh05▲ 10 net votes
helmet() sets a strict default CSP: scripts and styles only from your own origin, no inline scripts. A frontend that loads from a CDN, uses inline script tags, or shows images from another host breaks only once helmet is added. Configure helmet({ contentSecurityPolicy: { directives: { scriptSrc: ["'self'", 'cdn host'], imgSrc: ["'self'", 'data:', 'image host'] } } }) to list what you use. Read the browser console's CSP message: it names the blocked URL and directive.