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)

相关推荐
kyriewen18 分钟前
别再 console.log 了:5 个 Chrome DevTools 调试技巧,用过就回不去了
前端·javascript·面试
To_OC2 小时前
LC 1 两数之和:面试第一道必考题,暴力解法直接被面试官 pass
javascript·算法·leetcode
GuWenyue4 小时前
排序效率低?5分钟吃透快速排序,性能飙升至O(nlogn)
前端·javascript·面试
何时梦醒4 小时前
深入理解递归与快速排序 —— 从基础入门到手写实现
前端·javascript
bonechips4 小时前
LLM 的无状态:从 HTTP 协议到对话上下文工程
前端·javascript
胡志辉4 小时前
从 prototype 到 V8,看懂 JavaScript 原型链
前端·javascript
ping某6 小时前
专栏-null 和 undefined 到底是什么?
前端·javascript·后端
swipe9 小时前
从 0 到 1 理解 React 虚拟列表:定高、不定高与 Canvas 版本完整拆解
前端·javascript·面试
铁皮饭盒9 小时前
Bun执行python代码
前端·javascript·后端
zzzzzz31011 小时前
当甲方说'logo放大的同时再缩小一点'时,我用 AI 把这个需求做出来了
javascript·css·程序员