Getting around CORS using hls.js player in Blazor WASM

Sturla 176 Reputation points
2023-02-13T18:00:44.1733333+00:00

Since I´m having issues using Blazorise WASM version of plyr.io video player to play AES token videos because dash.js doesn´t support AES encryption I´m trying to implement this my self using hls.js

I have this repository Where it looks like its working but now I´m getting CORS errors trying to play the video stream

Access to XMLHttpRequest at 'https://myServer-euno.streaming.media.azure.net/0b4ba27d-2e47-45c3-b764-00713ede5d25/a6c1feb9-e9b7-4003-997d-6ca720e14da1.ism/manifest(format=mpd-time-cmaf,encryption=cbc)&aes=true&aestoken=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1cm46bWljcm9zb2Z0OmF6dXJlOm1lZGlhc2VydmljZXM6Y29udGVudGtleWlkZW50aWZpZXIiOiJjMmUzN2IyYy1iNTg5LTQxNTEtYjlkYy1mNTU1NDc2MGI4NDAiLCJ1cm46bWljcm9zb2Z0OmF6dXJlOm1lZGlhc2VydmljZXM6bWF4dXNlcyI6IjUiLCJuYmYiOjE2NzYzMDg0MTgsImV4cCI6MTY3NjMwOTMxOCwiaXNzIjoiaUJlaW5uaUlzc3VlciIsImF1ZCI6ImlCZWlubmlBdWRpZW5jZSJ9.oCwg5rPDna3VKiOYhP9zHyD6cSxuLweq5rQXYFeIsHc' from origin 'https://localhost:7101' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

So my question is: Can I do something about this in Azure Media Service or Blazor WASM? This works "fine" if I play the stream in IFrame like this. But I´m trying to get rid doff this code using Azure Media Player so it must be doing something under the hood, correct?

 <iframe src="//aka.ms/ampembed?url=@Video.DashUrl&aes=true&token=@Video.Token&autoplay=false"
                                    id="azuremediaplayer"
                                    name="azuremediaplayer"
                                    scrolling="no"
                                    frameborder="no"
                                    align="center"
                                    height="500px"
                                    width="672px"
                                    allowfullscreen
                                    class="embed-responsive-item"></iframe>
Azure Media Services
Azure Media Services
A group of Azure services that includes encoding, format conversion, on-demand streaming, content protection, and live streaming services.
313 questions
{count} votes

1 answer

Sort by: Most helpful
  1. SnehaAgrawal-MSFT 19,921 Reputation points
    2023-03-13T04:54:25.4533333+00:00

    Sturla My sincere apologies for late response here, Unfortunately, there are limitation on CORS handling in our streaming endpoint.

    Workaround for limitation on CORS responses from a streaming endpoint is to set CORS configuration from CDN side. If you are using the Azure CDN from Verizon Premium SKU you can update this via rules engine in the CDN supplemental portal.

    If you are using Azure CDN from Verizon Standard SKU you will need to work with CDN support to have this updated for them.

    Hope this helps.

    0 comments No comments