iamcal / oembed

The oEmbed Spec
http://oembed.com
MIT License
1.31k stars 637 forks source link

Single Page Applications #129

Open tutley opened 8 years ago

tutley commented 8 years ago

I believe there should be a way for single page applications to dynamically provide their oembed endpoint to the outside world.

For instance, if you are using Angular, Ember, etc, the HTML that a server receives when it requests say, and article: http://singlepageapp.com/articles/this-cool-article - It's just going to be the application layout with static, or meaningless META and LINK tags in the header. You can change those tags dynamically so they render in the user's browser, but that's not going to appear for any sort of scraper or programmatic discovery.

It seems like since the requesting agent already knows the URL that it's trying to get to, you should simply need to include this in your header:

<link rel="alternate" type="application/json+oembed" href="http://singlepageapp.com/api/article/oembed" title="singlepageapp oembed endpoint" />

The spec lays out the parameters, and the requester already knows the URL they want (or they wouldn't have been able to get to the page in the first place) so I'm confused as to why each page needs to include its URL in the provider discovery.

tutley commented 8 years ago

So, I found a way to work around this on the server side: when a requestor comes into the site with a direct link, the server can parse the string and figure out if it is a request to a client-side route that displays a sharable resource. If so, the server-side template can inject the relevant oembed links into the header.

spacemunkay commented 7 years ago

For simple single page apps without a pre-render server, it'd be nice to just specify the oembed endpoint without the parameters and allow the consumer to pass along the url for the page they're requesting.

So I'm curious as well to know why it's necessary to have the requested url in the provider discovery.