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)

相关推荐
像素之间11 分钟前
为什么运行时要加set NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service serve
前端·javascript·vue.js
M ? A14 分钟前
Vue转React实战:defineProps精准迁移实战
前端·javascript·vue.js·经验分享·react.js·开源·vureact
如意猴28 分钟前
【前端】002--怎样制作一个简历界面?
开发语言·前端·javascript
comerzhang65538 分钟前
手撕 V8:我是如何用 2.67ms 的心跳活捉 700ms 冻结幽灵的
javascript
im_AMBER39 分钟前
手撕发布订阅与观察者模式:从原理到实践
前端·javascript·面试
kyriewen1 小时前
重排、重绘、合成:浏览器渲染的“三兄弟”,你惹不起也躲不过
前端·javascript·浏览器
Wect2 小时前
JS 手撕:对象创建、继承全解析
前端·javascript·面试
3秒一个大2 小时前
深入理解 JS 中的栈与堆:从内存模型到数据结构,再谈内存泄漏
前端·javascript·数据结构
阿捞22 小时前
Inertia.js 持久布局实现原理
前端·javascript·html
w2sfot2 小时前
反AI逆向JS加密
javascript·人工智能·反ai