我正在学习网络安全的 COOP 和 COEP 功能。此处的规范https://html.spec.whatwg.org/multipage/origin.html#coep表示带有 unsafe-none 指令的 COEP 将允许获取跨域资源,因此它不会被 CORS 协议阻止。我编写了一个小示例 index.html 文件,它尝试从远程获取图像文件,但即使我将跨域嵌入策略响应标头设置为“不安全”,它也会被阻止。
我在某个地方有什么误解吗?我希望在 COEP unsafe-none 设置的提取操作中禁用 CORS 协议。
<html>
<body>
<script type="text/javascript">
fetch('https://third-party-test.glitch.me/check.svg', {
method: 'GET'
}).then(result => {
console.log('Success:', result);
});
</script>
</body>
NGINX configurations
location ~ /(\.html) {
add_header cross-origin-embedder-policy "unsafe-none";
}