简体   繁体   中英

Angular - Content Security Policy(CSP) support for inline style, eval etc

Angular official has no recommendation over the approach and support towards Content Security Policy. Has anyone has solution towards a strict CSP site with angular?

You can use Meta class shipped with angular to add a Meta tag.

import { Meta } from '@angular/platform-browser';
  ....
 constructor(private meta: Meta) 
   ...
       meta.addTag({http-equiv: 'Content-Security-Policy', content: `default-src 'self'; base-uri 'self'; ${moreFromVariable} `});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM