What I’m trying to do
I have a site that’s online through obsidian publish. It runs through a custom domain with cloudflare handling the redirection.
In some of the pages/notes, I’m including an iframe like:
<iframe src='https://attachments.kaanu.org/files/some-file.pdf' style='width:100%; height:1000px;' frameborder='0'></iframe>
This loads the PDF correctly on Firefox, but on Chrome/Safari, it is blocked by the browser.
A test page is at kaanu . daktre . com/Publications/aa+test (sorry, I’m not able to post links as my account is new on discourse)
On Firefox, the iframe loads the PDF correctly.
On Chrome, the network request is blocked with a “blocked:csp” status. There is no message in the developer console.
Things I have tried
I have tried setting various combinations of Content-Security-Policy (default-src, frame-src, script-src, connect-src, etc) through “Rules” feature in Cloudflare.
I have also tried setting Content-Security-Policy with frame-ancestors on the site the PDFs are hosted at.
I did find a workaround of using google docs and that works partly, but large files do not load through this.
I’m mostly tired by chromium making it incredibly hard by not showing any message in console of why the pdf is being blocked.
In Falkon browser, it did show a message like Refused to frame '' because it violates the following Content Security Policy directive: "frame-src 'self' https://*:* http://127.0.0.1:*".
But changing the frame-src CSP wasn’t helping. I am suspecting the empty string (‘’) won’t match any CSP? But where is this coming from? And why doesn’t firefox have this issue? I do not know.
Anyhow, my question is if anyone might be able to help with:
- why this is happening?
- any workaround
- any way to debug chromium/elsewhere such that I see the exact reason for CSP block
I do think one workaround could be to try and host the files directly on the domain. That would require me to set up custom domain proxying on my own (and I have had this failing randomly earlier)