// add Content Security Policy directives using a template string.
 
const ContentSecurityPolicy = `
  default-src 'self';
  script-src 'self';
  child-src example.com;
  style-src 'self' example.com;
  font-src 'self';
`
When a directive uses a keyword such as self, wrap it in single quotes ''.
In the header's value, replace the new line with a space.
 {
  key: 'Content-Security-Policy',
  value: ContentSecurityPolicy.replace(/\s{2,}/g, ' ').trim()
}
Version History
VersionChangesv13.3.0missing added.v10.2.0has added.v9.5.0Headers added.