D
D
dev1232019-11-07 15:50:09
JavaScript
dev123, 2019-11-07 15:50:09

How to allow my site to open in iframe for specific sites?

I need to allow certain sites to open my site in an iframe. The rest are banned. I read that it seems to be possible to do this using Content-Security-Policy, but I don’t quite understand how. Maybe there are other ways?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
dev123, 2019-11-08
@dev123

Found a better answer.
X-Frame-Options is considered a deprecated header.
It is recommended to use this:
Content-Security-Policy "frame-ancestors 'self' https://www.example.org ";
where https://www.example.org is a site that allows opening an iframe with your site

N
Nadim Zakirov, 2019-11-07
@zkrvndm

X-Frame-Options is not a panacea. Better hide the following JavaScript code on your site:

if (window != window.top) {
    document.body.innerHTML = '';
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question