- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个 html 页面,从 javascript 调用 HLS。获取 header “allow-control-allow-origin”的 CORS 错误。我正在使用 Adobe 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将发出请求的页面的名称,或带有“*”以允许来自任何域的请求。检查Enable CORS web site和 Configuring Apache HTTP Server documentation page获取更多信息。
此外,您还可以使用 HTML video
标签嵌入 HLS。当用户代理向video
源请求时,默认不会发送Origin
header,也不会在服务器响应中搜索CORS 相关的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获取更多信息。
关于javascript - 如何在 Adobe Media Server 中允许来自 Javascript 的 CORS 请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41158655/
我是一名优秀的程序员,十分优秀!