Reputation: 789
I am currently trying to allow specific websites to render an iframe of my website, but the following Content Security Policy added to my root web.config file doesn't seem to be doing the trick:
<add name="Content-Security-Policy" value="frame-ancestors https://https://iframetester.com/;" />
I get the following error:
Refused to frame 'My website URL' because an ancestor violates the following Content Security Policy directive: "frame-ancestors 'self'".
What is it that I'm missing/not understanding and how do I allow only specific websites to render an iframe from my website?
Upvotes: 0
Views: 716
Reputation: 789
I ended up finding the issue to my specific situation. The website I have has other applications code hosted upon it, which already had some HTTP Header Responses baked within it. This is why I wasn't able to change this setting.
Upvotes: 0
Reputation: 3465
It is the website you are trying to embed that has the setting frame-ancestors 'self', which means that it can only be framed by other pages with the same host. Other hosts are not allowed to frame it. Adding your own frame-ancestors only restricts who can frame your page. You have 3 options
Upvotes: -1