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)

相关推荐
小小前端_我自坚强12 分钟前
Vue 3 使用心得
前端·javascript·vue.js
华仔啊17 分钟前
前端真的需要懂算法吗?该怎么样学习?
前端·javascript
笔尖的记忆21 分钟前
【前端架构和框架】react准备知识
前端·javascript
渣哥22 分钟前
从配置文件到 SpEL 表达式:@Value 在 Spring 中到底能做什么?
javascript·后端·面试
一小池勺44 分钟前
改变上下文的 API:call, apply, bind
前端·javascript
Keepreal4961 小时前
使用Canvas绘制转盘
javascript·vue.js·canvas
前端Hardy1 小时前
Vue 高效开发技巧合集:10 个实用技巧让代码简洁 50%+,面试直接加分!
前端·javascript·vue.js
ᖰ・◡・ᖳ2 小时前
JavaScript:神奇的ES6之旅
前端·javascript·学习·es6
前端Hardy2 小时前
HTML&CSS:一眼心动的 SVG 时钟
前端·javascript·css
又是忙碌的一天3 小时前
前端学习 JavaScript
前端·javascript·学习