eshaz / icecast-metadata-js

Browser and NodeJS packages for playing and reading Icecast compatible streaming audio with realtime metadata updates.
155 stars 20 forks source link

How do we set the CORS headers on the icecast2 server? #103

Closed dzhen19 closed 2 years ago

dzhen19 commented 2 years ago

Hey @eshaz! This isn't really a problem relating to the library but how do you set up the Access-Control-Allow-Headers on the icecast server?

Thanks!

eshaz commented 2 years ago

You can add the CORS headers to Icecast by modifying the your server's configuration file. It's described here in the documentation for Icecast: https://www.icecast.org/docs/icecast-trunk/config_file/#http-headers

If you want ICY metadata, you'll also need to add the headers described here in the docs for this library: https://github.com/eshaz/icecast-metadata-js#cors

GuanyunLu commented 2 years ago

@eshaz Hello! Thank you for your information. I've edited my icecast2 config file as above to get ogg metadata, however, I still get CORS errors in the browser. In this case, what should I do to solve this problem? I run my icecast2 on a VPS, my website is on Github Pages.

eshaz commented 2 years ago

What's the CORS error that you're seeing? The error will tell you the CORS policy that that is blocking your request. You then need to update the policy in your server to unblock that, but what you change depends on the details of the error.

GuanyunLu commented 2 years ago

Oooh! I'm terribly sorry, I forgot to add the port number in the audio source, so I got 404 all the time. It was my own fault.😂Thank you again for your patience and instructions! Have a good day(or night)!