Unity WebGL app with redirect API Twitch

Hi, I’m Lucio, it’s my first post here and sorry if it isn’t the correct area of the forum.

I’m developing a web app using Unity WebGL. This app will show my stream content from my Twitch’s channel to my html page on my server. I found some Unity plugins that can communicate with Twitch and can read HLS format (Twitch video format?), and in my interface it works perfectly (also if I build an .exe).

Now I’m in trouble with the web version of the app. If I upload on my server, the console give me some errors related to CORS policy. In particular:

Refused to get unsafe header “ETag”

and

index.html:1 Access to XMLHttpRequest at ‘https://video-weaver.sea01.hls.ttvnw.net/v1/playlist/ […] .m3u8’ from origin ‘http://www.[myHost].it’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.

I found some documentation on the web. I realized that I need to make a request from my server to the Twitch server, using some header like “Access-control- […]” and maybe some “fetch” or “XHMHttpRequest” on javascript (?).

I’m in the dark now, because I don’t know anything about this policy arguments, and I cannot find how and where I can put the headers or the javascript objects.

I can say that my output application is in form of an .html page and some .js pages. I didn’t find where I can put this request in these files, and also I don’t know what kind of language is “Access-control- […]”.

Please, someone can help me?
Thanks for your time and sorry for my english.

Lucio

Using anything other than Twitch’s Embeded player https://dev.twitch.tv/docs/embed to display streams is a violation of the Twitch Developer Agreement. You shouldn’t be doing what you’re attempting to do.

Actually you need to change the server to add those headers. And you can’t change Twitch’s Servers.

Becuase, as Dist points out, you shouldn’t be doing this

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.