# Iframe onebox has stopped working

**URL:** https://meta.discourse.org/t/iframe-onebox-has-stopped-working/56091
**Category:** Support
**Created:** [January 20, 2017, 6:58pm UTC](https://meta.discourse.org/t/iframe-onebox-has-stopped-working/56091 "2017-01-20T18:58:57Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [January 20, 2017, 6:58pm UTC](https://meta.discourse.org/t/iframe-onebox-has-stopped-working/56091/1 "2017-01-20T18:58:57Z")

</div>

I’ve set up one of our organisation’s systems to provide a onebox using this HTML tag

As an example: on the page [https://domain.here/2345](https://domain.here/2345), I have this tag:

```plaintext
<link rel="alternate" type="application/json+oembed" href="https://domain.here/2345/oembed_json/" title="Onebox Embed">

```

`https://domain.here/2345/oembed_json/` then provides

```plaintext
{"version": "1.0", "type": "rich", "html": "\u003ciframe src=\"https://domain.here/2345/embed/\" frameborder=\"0\" width=\"100%\" height=\"250\"\u003e\u003c/iframe\u003e"}

```

This used to work great, but has stopped working in the last few weeks (not sure exactly when). Currently on the latest version of Discourse, and I can reproduce the issue on meta. Oembed shows up fine on [Iframely URL Debugger - Open Graph, Twitter Cards, oEmbed](http://iframely.com/debug)

I’d rather not make the URL to the actual system public, but can PM it to someone if that would help.

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [January 20, 2017, 7:39pm UTC](https://meta.discourse.org/t/iframe-onebox-has-stopped-working/56091/2 "2017-01-20T19:39:54Z")

</div>

Any chances you could share one example? Even via a PM is fine.

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [February 25, 2017, 3:50pm UTC](https://meta.discourse.org/t/iframe-onebox-has-stopped-working/56091/3 "2017-02-25T15:50:56Z")

</div>

I’ve setup a very simple example which displays the same issue. This URL should be oneboxing and becoming an iframe:

> **[Test Page to be embedded](http://discourse-test.taylorhq.co.uk)**

`http://discourse-test.taylorhq.co.uk`

Works [fine on the iframely debug tool](http://iframely.com/debug?uri=http%3A%2F%2Fdiscourse-test.taylorhq.co.uk%2F) and used to work fine on Discourse until about a month ago. Any ideas on what I can do to get this working again?

> **index.html**
>
> ```plaintext
> <html>
> <head>
> <title>Test Page to be embedded</title>
> <link rel="alternate" type="application/json+oembed" href="http://discourse-test.taylorhq.co.uk/oembed_json.json" title="Embed JSON">
> </head>
> <body>
> This is a web page which has an application/json+oembed tag linking to <a href="http://discourse- test.taylorhq.co.uk/oembed_json.json">Here</a>
> </body>
> </html>
> 
> ```

> **oembed\_json.json**
>
> ```plaintext
> {  
> "type":"rich",
> "html":"\u003ciframe src=\"http://discourse-test.taylorhq.co.uk/embed.html\" frameborder=\"0\" width=\"100%\" height=\"250\"\u003e\u003c/iframe\u003e",
> "version":"1.0"
> }
> 
> ```

> **embed.html**
>
> ```plaintext
> <html>
> <head>
> <title>Test Page</title>
> </head>
> <body>
> This is the page that should be displayed in the iframe
> </body>
> </html>
> 
> ```

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [February 26, 2017, 2:06am UTC](https://meta.discourse.org/t/iframe-onebox-has-stopped-working/56091/4 "2017-02-26T02:06:50Z")

</div>

I don’t think we support arbitrary embeds like that. The proper opengraph or oembed should have title, summary, image etc fields.

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [February 26, 2017, 2:14am UTC](https://meta.discourse.org/t/iframe-onebox-has-stopped-working/56091/5 "2017-02-26T02:14:01Z")

</div>

There are references to “rich” embeds with iframes in the “generic” onebox:

> <https://github.com/discourse/onebox/blob/fa6ffc4e3b706567497a30908b72b26386562693/lib/onebox/engine/whitelisted_generic_onebox.rb#L310>

I believe the “whitelist” got removed fairly recently… could that be the issue? My site is no longer whitelisted?

---

<div class="post-metadata">

### Author: ![Mittineague](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittineague/32/114259_2.png) [@Mittineague](https://meta.discourse.org/u/Mittineague)
#### Post date: [February 26, 2017, 2:35am UTC](https://meta.discourse.org/t/iframe-onebox-has-stopped-working/56091/6 "2017-02-26T02:35:40Z")

</div>

> [@david](#):
>
> I believe the “whitelist” got removed fairly recently… could that be the issue? My site is no longer whitelisted?

I don’t think so. AFAIK the approach was changed from “don’t onebox unless whitelisted” to “onebox all the things unless blacklisted”  
Conditional upon the “thing” being oneboxable of course.

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [March 10, 2017, 3:22pm UTC](https://meta.discourse.org/t/iframe-onebox-has-stopped-working/56091/7 "2017-03-10T15:22:48Z")

</div>

I’ve finally tracked down the cause of this. It broke on 6th Jan, after this commit by @zogstrip

> <https://github.com/discourse/onebox/commit/fa6ffc4e3b706567497a30908b72b26386562693>

My iframe already has a fixed height, defined in pixels like this

```plaintext
<iframe src="http://discourse-test.taylorhq.co.uk/embed.html" frameborder="0" width="100%" height="250"> </iframe>

```

The commit above added checks that `data[:height]` exists before accepting a ‘rich’ onebox… however, it’s not pulling that height from the parsed HTML, it’s trying to get it from the oembed JSON file. @zogstrip is this expected behaviour? Should I be defining the height of the iframe in the oembed JSON?

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [May 12, 2019, 2:25am UTC](https://meta.discourse.org/t/iframe-onebox-has-stopped-working/56091/8 "2019-05-12T02:25:51Z")

</div>



---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [May 12, 2019, 2:49am UTC](https://meta.discourse.org/t/iframe-onebox-has-stopped-working/56091/9 "2019-05-12T02:49:22Z")

</div>

Are we all good on this now?

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [May 13, 2019, 4:26pm UTC](https://meta.discourse.org/t/iframe-onebox-has-stopped-working/56091/10 "2019-05-13T16:26:24Z")

</div>

It’s weird looking back on support requests from before I joined the team 😂

What I said above is still true. You need to explicitly specify a height for the iframe in the oembed json. You now also need to add the iframe domain to the whitelist in site settings (In March 2017 this was not required). In summary, onebox doesn’t really support the [“rich oembed”](https://oembed.com/) specification too well.

Even in the spec, they have security concerns

> Consumers may wish to load the HTML in an off-domain iframe to avoid XSS vulnerabilities.

Given the lack of sites actually using rich oembed, I think it’s fine to leave things as-is.

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [June 12, 2019, 4:26pm UTC](https://meta.discourse.org/t/iframe-onebox-has-stopped-working/56091/11 "2019-06-12T16:26:26Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
