0

I'm using hls.js plus html5 < video > tag in my browser in order to view live video streams.

However, if I try to give hls.js a link to a video that is on a different site, I get a CORS error.

I was told that I could use an HLS proxy on my server to help prevent CORS errors. But I'm wondering how to do that.

Let's say as an example only, I wanted to play a youtube live stream from my website in the browser using hsl.js (this is just an example). I give hls.js the URL to YouTube stream since the browser is currently on my website, hls.js in the browser will go directly to the YouTube website bypassing my server all together causing the CORS error, so how will using an HLS proxy help?

Does anybody know how to solve this CORS problem? Is my whole set up wrong? How to do it? Thanks

Reegan Miranda
  • 2,879
  • 6
  • 43
  • 55
programmer
  • 71
  • 1
  • 11
  • You would run an [HLS Proxy](https://www.hls-proxy.com/) on a **server** that your front-end **does** have access to (either by being on the same host or by configuring CORS access). You would then make all requests through this proxy. Server-side code is not subject to CORS restrictions – Phil Aug 09 '19 at 05:47
  • @Phil thanks for the comment, i still dont understand. Someone comes to my website/server on their browser, the site shows them a box for them to enter a URL of the live stream they want to see, for example http://www.youtube.com/file.m3u8. This URL is passed to the browser which goes directly to YouTube to get and play the stream causing the CORS error since they are on my site and not actually on Youtube. This request to YouTube doesnt go thu my server the browser itself goes directly to youtube. I dont understand how an HLS proxy on my server help anything since its not involved anywhere. – programmer Aug 09 '19 at 12:58

0 Answers0