Show a site in an iframe for testing
You embed a page in an iframe and get a blank frame, or "refused to connect", with a console message about X-Frame-Options or frame-ancestors. The page told the browser not to be framed by other sites. That protects its users from clickjacking, so the right fix is usually on the page's side.
The two headers that block it
X-Frame-Options: DENYorSAMEORIGIN, the older one.Content-Security-Policy: frame-ancestors 'self'(or a list of allowed origins), the newer one. If both are present, browsers go byframe-ancestors.
The proper fix: allow your origin
If you own the framed page, list the sites that may frame it: Content-Security-Policy: frame-ancestors 'self' https://app.example.com, and drop X-Frame-Options. For local development, add http://localhost:3000 in your dev config only.
For testing: remove the headers in the browser
When you can't change the framed page (a third-party widget, a staging site), a header extension can remove those response headers in your browser only. In Headerwise, the Allow the site in an iframe preset removes X-Frame-Options and Content-Security-Policy. Then:
- add an only on filter for the framed site, so other sites keep their protection;
- reload the page with the iframe.
Content-Security-Policy removes all of it, not only frame-ancestors: the page loses its script and style restrictions too while the profile is on. Keep it to the one site, and switch the profile off when you're done (or let it switch itself off with "On for 15 minutes").Still blank?
- The framed page may check
window.topin JavaScript and refuse to render ("frame busting"); headers can't change that. - Cookies: a framed site is a third party, so its login cookies need
SameSite=None; Secure, and browsers that block third-party cookies won't send them at all.