Angular Content security policy

When serving your Angular application, the server should include a randomly-generated nonce in the HTTP header for each request. You must provide this nonce to Angular so that the framework can render <style> elements. You can set the nonce for Angular in one of two ways:

Way 1: Set the ngCspNonce attribute on the root application element as <app ngCspNonce="randomNonceGoesHere"></app>. Use this approach if you have access to server-side templating that can add the nonce both to the header and the index.html when constructing the response.

Way 2: Provide the nonce using the CSP_NONCE injection token. Use this approach if you have access to the nonce at runtime and you want to be able to cache the index.html.

![在这里插入图片描述](https://i-blog.csdnimg.cn/direct/db71a512c7e242d5ad18cfab313e3578.png![在这里插入图片描述](https://i-blog.csdnimg.cn/direct/a9adae240ab9439c86348a9b42f8ebec.png)

相关推荐
阿芯爱编程19 分钟前
最长和谐子序列,滑动窗口
前端·javascript·面试
烛阴1 小时前
开发者神器:如何在浏览器控制台玩转第三方库,让调试效率翻倍!
前端·javascript
拉不动的猪2 小时前
JQ常规面试题
前端·javascript·面试
新中地GIS开发老师2 小时前
三维GIS开发cesium智慧地铁教程(5)Cesium相机控制
javascript·arcgis·智慧城市·大学生·gis开发·webgis·地理信息科学
Shimeng_19892 小时前
前端如何通过(手机)扫描二维码下载app
前端·javascript·vue.js·二维码·扫描二维码下载软件app
Mr...Gan3 小时前
TypeScript
开发语言·javascript·typescript
MZWeiei3 小时前
MVVM 模式,以及 Angular、React、Vue 和 jQuery 的区别与关系
vue.js·react.js·angular.js
前端 贾公子4 小时前
《Vuejs设计与实现》第 8 章(挂载与更新)
开发语言·前端·javascript
半碗水4 小时前
缝缝补补
前端·javascript
用户2519162427114 小时前
ES6之类的其他书写方式
javascript·ecmascript 6