Ages ago I wrote up a bit about how your public sites should consider implementing Content Security Policy because of all the hacks it can prevent. In a bit of frustrating irony, I was tripped up by a problem caused precisely because Sitecore have added some CSP headers to their own code. Google came up empty on this, so I'm documenting it for the next person who gets bitten.
Chrome's Content Security Policy code is blocking Sidekick's window... Checking Dev Tools showed this error:
Refused to frame 'http://cm.whatever.localhost/' because it violates the following Content Security Policy directive: "default-src 'self' https://apps.sitecore.net". Note that 'frame-src' was not explicitly set, so 'default-src' is used as a fallback.
And looking at the underlying markup I can see that the "window" on the Sitecore desktop is actually an iFrame:
So there are a few interesting things here:
http://
request - but the overall page request is using
https://
. Chrome gets very unhappy at "mixed content" these days, so that would be a bad thing.http
... And if you write code that processes URLs inside a container, you need to pay attention to the
X-Forwarded-*
headers - as they can tell you about the original request, before any proxies or SSL termination got in the way.frame-src
config
That means it'll fall back to using the
default-src
setting - which is configured as
self
here. That means it will disallow any frame request that doesn't come from the same scheme (https), port and host.It turns out that sneakily, Sitecore pushed some config into V9.3 which writes out a basic CSP for any pages under
/sitecore
. This isn't mentioned in the release notes for either V9.3 or V10, but it's
alluded to in this Knowledge Base article, which says that the lack of CSPs is "fixed" with V9.3.
My attempts at Google to work out how this was being done failed, but
Jeff L'Heureux
at Sitecore solved the conundrum for me. It's been configured as a
<customHeaders>
setting in the site web.config:
So you can tweak it if you need to - if you need to allow certain other urls just update your
web.config
with some XDT before you release.
But it's still possible you might hit this issue if you iFrame your own custom apps into a window on the Sitecore desktop. So maybe this will be of help...
↑ Back to top