Facebook oEmbed端点CORS错误

Facebook oEmbed endpoint CORS Error

本文关键字:错误 CORS 端点 oEmbed Facebook      更新时间:2023-09-26

我试图向facebook的oembed发出XHR请求,但遇到了CORS错误。有人知道这是否是因为Facebook不允许向oembed端点发出CORS请求吗?如果是这样的话,为什么不允许呢?端点应该在浏览器之外使用吗?

XMLHttpRequest cannot load https://apps.facebook.com/plugins/
post/oembed.json/?url=https://www.facebook.com/notes/mark-zuckerberg/
a-letter-to-our-daughter/10153375081581634.
No 'Access-Control-Allow-Origin' header is present on the requested resource.
Origin 'http://localhost:8000' is therefore not allowed access.

我也在与其他提供商打交道:YouTube、Twitter、Vine、Instagram。有些人似乎允许这样做:Vimeo和Soundcloud。

大多数oEmbed提供程序不允许跨源资源共享AFAIK。因此,为了避免这种情况,您可以从服务器调用oEmbed end point,而不是从浏览器/移动客户端调用,这样您就可以逃离CORS。