admin管理员组文章数量:1302333
So I'm putting a plugin together that will allow me to connect multiple client sites with an online service.
I can get the service vendors snippet to load, but once you interact with it, that's where things get tricky and it refuses to load an (I guess) iframe... ...it's pretty poorly documented.
Refused to load / because it does not appear in the frame-ancestors directive of the Content Security Policy.
That's the console log error I was receiving.
So I jumped back into my plugin and added the following:
function bbti_send_headers() {
header( "Content-Security-Policy: frame-ancestors /; frame-src /;" );
}
add_action( 'send_headers', 'bbti_send_headers' );
Now, when I reload the page I'm still getting the same error Refused to load /... etc...
However, if I look at the network panel and check the page's headers this is what I get:
HTTP/1.1 200 OK
Content-Encoding: gzip
Content-Security-Policy: frame-ancestors /; frame-src /;
So the header is there but still getting the same error from the script.
Anyone know what it is I missed?
So I'm putting a plugin together that will allow me to connect multiple client sites with an online service.
I can get the service vendors snippet to load, but once you interact with it, that's where things get tricky and it refuses to load an (I guess) iframe... ...it's pretty poorly documented.
Refused to load https://www.service-domain/ because it does not appear in the frame-ancestors directive of the Content Security Policy.
That's the console log error I was receiving.
So I jumped back into my plugin and added the following:
function bbti_send_headers() {
header( "Content-Security-Policy: frame-ancestors https://www.service-domain/; frame-src https://www.service-domain/;" );
}
add_action( 'send_headers', 'bbti_send_headers' );
Now, when I reload the page I'm still getting the same error Refused to load https://www.service-domain/... etc...
However, if I look at the network panel and check the page's headers this is what I get:
HTTP/1.1 200 OK
Content-Encoding: gzip
Content-Security-Policy: frame-ancestors https://www.service-domain/; frame-src https://www.service-domain/;
So the header is there but still getting the same error from the script.
Anyone know what it is I missed?
Share Improve this question asked Mar 13, 2021 at 4:15 Tony DjukicTony Djukic 2,2774 gold badges18 silver badges34 bronze badges 8
https://www.service-domain/
", then it's probably because the resource/page atservice-domain
is disallowing itself from being put in an iframe or frame (within certain pages). So basically, you'd need to contact the service vendor for guidance on fixing the issue.. (or the proper way to load their snippet on your plugin page). And actually, it's them who would add the header (in yourbbti_send_headers()
) and not your plugin.. I mean, if the header was actually needed. – Sally CJ Commented Mar 16, 2021 at 11:49service-domain/Client%20Company%20Name/?search
which returns a 404, but if you edit the string manually and drop it into your browser asservice-domain/clientcompanyname/?search
you get the expected result. (Troubleshooting is exponentially more difficult when you've got multiple errors and you don't know if they're separate or if one is the cause of the other.) – Tony Djukic Commented Mar 16, 2021 at 14:19本文标签: