Onebox Does Not Display - iFramely Passes

AI-generated summary

The discussion revolves around Onebox not displaying previews for certain sites, with users investigating the cause. Edward_D_Avignon notes that while iframely.com shows the preview correctly, the Discourse Onebox fails. merefield suggests the issue may be related to the crawler being rejected, proposing a plugin solution for better Onebox functionality. Falco identifies that the target site blocks User Agents containing “forum,” which explains the failure. merefield confirms this and suggests modifying the User Agent in 100-onebox_options.rb by removing “forum” from the string, highlighting the need for more transparency in Onebox error handling.

I have noticed very few sites I attempt to use a Onebox for are not working. I checked

against iframely.com and it displays as expected. Iframely URL Debugger - Open Graph, Twitter Cards, oEmbed does not indicate any errors.

Is there something else I can check?

My guess is you are having your crawl rejected (and this is happening here on meta too).

But I have a solution, but it’s not 100% free:

I just tested this on two of my sites, one equipped with the plugin, and one without, and it works on the one equipped.

My pleasure! :wink:

One of the issues here is that Discourse/Onebox could be a heck of a lot more transparent about the way it handles a failure. I guess that’s a stretch feature, but it would be nice if there was more feedback to the user pasting the link (or even just the admins).

I checked my /logs on the site which failed and do not see any extra information wrt to the failed preview …

This is funny, that site blocks “forum” in the User Agent:

Works:

  • Discourse
  • Discourse Onebox
  • Discourse Onebox v1.8.0.beta13

Don’t Work:

  • Discourse Forum Onebox v1.8.0.beta13
  • Discourse Forum Onebox
  • Discourse Forum
  • Forum

Yes, I can reproduce that from a VPS using curl -A "-string-"! Can we have a setting to change the user agent? :wink:

In this case that would be a lot less hassle :slight_smile:

Oh wait, I see a file:

discourse/config/initializers/100-onebox_options.rb

require_dependency 'twitter_api'

Onebox.options = {
  twitter_client: TwitterApi,
  redirect_limit: 3,
  user_agent: "Discourse Forum Onebox v#{Discourse::VERSION::STRING}"
}

Take the word forum out?

I could easily add this to my plugin of course …