如何在 Adob​​e Media Server 中允许来自 Javascript 的 CORS 请求

How to allow CORS request from Javascript in Adobe Media Server

我有一个 html 页面,从 javascript 调用 HLS。获取 header "allow-control-allow-origin" 的 CORS 错误。我正在使用 Adob​​e Media Server 4.5。 我如何允许来自 javascript 的 CORS 请求?

Adobe 媒体服务器使用 Apache HTTP 服务器。要启用 CORS,您需要将以下行添加到 Apache HTTP 服务器配置文件:

Header set Access-Control-Allow-Origin "your_page_origin"

您需要将 "your_page_origin" 替换为 origin of the page that will make requests, or with "*" to allow requests from any domain. Check Enable CORS web site and Configuring Apache HTTP Server documentation page 以获取更多信息。

此外,您可以使用 HTML video 标签嵌入 HLS。当用户代理向 video 源发出请求时,默认不会发送 Origin header,并且不会在服务器响应中搜索 CORS-related header。在这种情况下,您不需要更改服务器配置。 Apple 建议在 introduction to HTTP Live Streaming Overview:

中使用 video 标签

Important: Where possible, use the <video> tag to embed HTTP Live Streaming, and use the <object> or <embed> tags only to specify fallback content.

查看 How can I play Apple HLS live stream using html5 video tag thread 了解更多信息。