An iframe is not working, the console has a red line about frames in it, and somebody has already said the word CORS. That word is almost always wrong here, and the reason it is wrong matters, because the two things people are actually looking at have different owners and opposite fixes.

There are two failures. One means the page refused to be embedded. The other means the page was embedded perfectly well and your code cannot read inside it. They look similar in a screenshot and share almost nothing else.

Failure one: it refused to load at all

The frame is empty. The console says the document refused to be displayed because of X-Frame-Options, or because of a Content Security Policy.

This is a decision made by the site you are embedding, delivered in the response you asked for. MDN is precise about what the header is for: it indicates “whether a browser should be allowed to render the document in a <frame>, <iframe>, <embed> or <object>”, and sites use it “to avoid clickjacking attacks and some cross-site leaks, by ensuring that their content is not embedded into other sites”.

There are two values that still mean anything. DENY means the document “cannot be loaded in any frame, regardless of origin”, including by the site that served it. SAMEORIGIN means it “can only be embedded if all ancestor frames have the same origin as the page itself”.

The important part is whose header it is. It travels with the document being framed, not with the page doing the framing. So nothing in your HTML, your server configuration or your framework will change it. If you do not control that other origin, you cannot fix this, and the honest options are to ask them to allow your origin or to stop embedding them.

Three ways teams waste a day on this one

Reaching for ALLOW-FROM. It was the directive for permitting a specific origin and it is obsolete. MDN’s wording is worth reading carefully: “Modern browsers that encounter response headers with this directive will ignore the header completely.” So adding it does not narrow anything. It removes the protection you thought you were configuring, and the frame may well start working, for the wrong reason. The modern equivalent is the frame-ancestors directive in a Content Security Policy.

Putting it in a meta tag. MDN carries an explicit warning: setting it inside a <meta> element “has no effect. X-Frame-Options is only enforced via HTTP headers.” A deployment where response headers are awkward is exactly where somebody tries this, and it fails silently in the most expensive way, which is that it looks done.

Changing headers on the wrong site. Adding X-Frame-Options to your own responses does nothing about a third party refusing to be framed. It only changes who may embed you.

Failure two: it loaded, and you cannot read it

Different message, different world. The frame renders. Your script reaches into it, for the document, the height, a form field, and the browser blocks the access with a message about a cross-origin frame.

Nothing is broken. This is the same-origin policy doing the single thing it exists to do. In MDN’s words, when two documents do not have the same origin, cross-document references “provide very limited access to Window and Location objects”.

Very limited is a specific list rather than a vague warning. Across origins you keep postMessage, blur, focus and close; you can read closed, frames, length, opener, parent, self, top and window; location.href is writable but not readable, which is why you can navigate a frame you cannot inspect. Everything else, including the entire document, is gone.

The fix is not a header. MDN states it plainly: “To communicate between documents from different origins, use window.postMessage.” The embedded page posts what it is willing to share, the parent listens, and both sides check the origin on the way through. That is the supported route and the only one that survives.

And the old trick is no longer a trick. Setting document.domain to a shared suffix is deprecated, and MDN says why: it “undermines the security protections provided by the same origin policy, and complicates the origin model in browsers, leading to interoperability problems and security bugs”.

Why CORS is the wrong word for both

CORS governs whether your JavaScript may read the response to a request it made. It is about fetch and XMLHttpRequest.

Framing is not a request your script reads, and reaching into a loaded frame is not a request at all. So no Access-Control-Allow-Origin header fixes either failure, which is why the afternoon spent adding one produces nothing. If the error genuinely mentions a CORS policy, you are looking at a third thing again.

For completeness, a refusal to frame can also surface as ERR_BLOCKED_BY_RESPONSE, which is one of the three Chromium errors that all read as blocked and are worth telling apart for the same reason as these two.

The reason this arrives as a bug report you cannot reproduce

Both failures are invisible in a way that costs real time.

The console message lives on the parent page, and what the user sees is a blank rectangle where a widget should be. A screenshot of that rectangle contains none of the diagnosis. The person sending it has no reason to open developer tools, and would not know which of the two lines mattered if they did.

Worse, both are conditional. The embedded site’s headers can differ between its own environments, a corporate proxy can add or strip a header in transit, and a policy can be tightened on a Tuesday by a team you have never spoken to. So the frame works on your machine and not on theirs, or it worked last week and does not today, with nothing in your repository having changed.

Which is the ordinary shape of it: the answer is one line in somebody else’s console, and the report you receive is a picture of an empty box.

The short version

  • Two errors, not one. “Refused to display” is the embedded site saying no. “Blocked a frame with origin” is the same-origin policy refusing you access to a frame that loaded fine.
  • The first is governed by a header on the document being framed, so it is not yours unless you own that origin.
  • ALLOW-FROM is obsolete and makes browsers ignore the header entirely, and a <meta> tag never worked at all.
  • The second is fixed with postMessage, not with headers, and document.domain is deprecated.
  • CORS fixes neither, because neither is your script reading a response.
  • The user sees a blank box and the explanation is in a console they will never open.