我在将
Checkout Plus
支付网关集成到我的 Laravel 应用程序中时遇到问题。在执行 JS 代码时,我遇到了 CSP 错误。
Refused to frame 'https://test.payu.in/' because an ancestor violates the following Content Security Policy directive: "frame-ancestors 'self' *.facebook.com payments.np.flydubai.com *.instagram.com *.meta.com *.myshopify.com".
我尝试在页面上添加以下标题
<?php
header("Access-Control-Allow-Origin: *");
header('Access-Control-Allow-Credentials: true');
header('Access-Control-Max-Age: 86400');
header("Access-Control-Allow-Methods: GET, POST, OPTIONS");
header('X-Frame-Options', 'ALLOW FROM *');
header("Content-Security-Policy: frame-ancestors 'self' *.payu.in *.facebook.com payments.np.flydubai.com *.instagram.com *.meta.com *.myshopify.com *.payubiz.in *.payumoney.com *.google.com https://test.payu.in/; frame-src 'self' *.payu.in *.google.com https://test.payu.in/;");
也尝试通过中间件添加相同的内容,但每次错误都是相同的。
就像评论中提到的,test.payu.in 的所有者是唯一可以更改标头的人。你无法改变你的行为。
如果您使用 iframe,您应该查看 有关处理 iframe 的官方文档。