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.com/ 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.com/; frame-src https://www.service-domain.com/;" );
}
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.com/... 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.com/; frame-src https://www.service-domain.com/;
So the header is there but still getting the same error from the script.
Anyone know what it is I missed?
https://www.service-domain.com/
", then it's probably because the resource/page atservice-domain.com
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.service-domain.com/Client%20Company%20Name/?search
which returns a 404, but if you edit the string manually and drop it into your browser asservice-domain.com/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.)