简体   繁体   English

Chromecast对HLS的支持,Amazon S3上的CORS错误

[英]Chromecast support for HLS, CORS error on Amazon S3

I am trying to integrate HLS streams in my chromecast app. 我正在尝试在chromecast应用程序中集成HLS流。

The receiver part is fine because i checked it with multiple HLS Stream urls. 接收器部分很好,因为我用多个HLS流url检查了它。

i just cant get the CORS bit to operate correctly. 我只是无法让CORS位正确运行。

I am using Amazon AWS S3. 我正在使用Amazon AWS S3。 I have set the CORS for my bucket. 我已经为我的存储桶设置了CORS。

<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
    <CORSRule>
        <AllowedOrigin>*</AllowedOrigin>
        <AllowedMethod>GET</AllowedMethod>
        <AllowedMethod>PUT</AllowedMethod>
        <AllowedMethod>POST</AllowedMethod>
        <AllowedMethod>DELETE</AllowedMethod>
        <AllowedHeader>*</AllowedHeader>
    </CORSRule>
</CORSConfiguration>

in my assumption this should allow access from all domains to access the resources inside this bucket. 在我的假设中,这应该允许来自所有域的访问来访问此存储桶中的资源。

But still i am getting the following error in javascript from Chromecast. 但是我仍然从Chromecast收到JavaScript中的以下错误。

XMLHttpRequest cannot load http://s3-eu-west-1.amazonaws.com/interactive-encoding-out/watermark-sintel-test/playlist.m3u8. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://s3-eu-west-1.amazonaws.com' is therefore not allowed access. 

Try this https://github.com/TOMODOcom/TOMODOkorz . 试试这个https://github.com/TOMODOcom/TOMODOkorz It works for me. 这个对我有用。

TOMODOkorz allows you to make cross-origin requests to any domain. TOMODOkorz允许您向任何域提出跨域请求。 It will remove any cross-origin restrictions from your site once you add it to your site. 将其添加到网站后,它将从您的网站中删除所有跨域限制。 Allows easy Cross-origin resource sharing 允许轻松的跨域资源共享

Based on http://docs.aws.amazon.com/AmazonS3/latest/dev/cors.html , your example looks a bit more complex than nescessary. 基于http://docs.aws.amazon.com/AmazonS3/latest/dev/cors.html ,您的示例看起来比不必要的复杂。

<CORSConfiguration>
 <CORSRule>
   <AllowedOrigin>*</AllowedOrigin>
   <AllowedMethod>GET</AllowedMethod>
 </CORSRule>
</CORSConfiguration>

Is probably all that you need. 可能就是您所需要的。 That said, do you own the bucket interactive-encoding-out ? 就是说,您是否拥有存储桶交互式编码输出 That might be the issue. 这可能是问题所在。 You might need to copy the segments to your own bucket where you can set this header before it will work. 您可能需要将这些段复制到自己的存储桶中,然后才能在其中设置此标题。

Right now i have used corsproxy as a reversed proxy that adds cors headers to my request. 现在,我已经使用corsproxy作为反向代理,将cors标头添加到我的请求中。 Really recommand this solution. 真的建议这个解决方案。 No need for a custom receiver app this way. 这样就无需自定义接收器应用程序。 just install the corsproxy somewhere on your server 只需将corsproxy安装在服务器上的某个位置

run the cors proxy: 运行cors代理:

$ corsproxy <SERVER_IP> <DESIRED_PORT>

and run the request like : 并像这样运行请求:

http://<SERVER_IP>:<DESIRED_PORT>/<YOUR REQUEST>

install from: https://www.npmjs.org/package/corsproxy 从以下位置安装: https : //www.npmjs.org/package/corsproxy

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM