Configuring Azure Storage CORS settings for embedding video content

In my project, I am working on creating a panorama tour that includes additional content such as videos using three.js and React.

The videos I am using are stored on a private Azure storage, where I generate SAS tokens for specific video files.

When attempting to play a video from the GUI, the CORS is working well:

        <video id={uid} autoPlay controls controlsList="nodownload">
            <source style={{objectFit: "cover"}}
                    src={videoPath}
                    type={"video/mp4"}/>
            </video> //this one is working

In this case, the videoPath is located on www.mystorage.azurelink.net, not on my origin.

However, when I create a video element dynamically per view:

    const videosRoot = document.getElementById("videosroot")

    const video: HTMLVideoElement = document.createElement("video")
    video.id = `video-${this.uid}`
    video.crossOrigin = "anonymous"
    video.playsInline = true
    video.muted = true
    video.style.display = "none"

    const source = document.createElement("source")
    source.id = `video-source-${this.uid}`

    video.appendChild(source)

    videosRoot.appendChild(video)
....
    const videoTexture = new three.VideoTexture(videoElement)

I encountered an error:

Access to video at 'https://mystorage.blob.core.windows.net/MYCONTAINER/Videos/default.mp4?MYSASTOKEN'
from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

and

net::ERR_FAILED 206

The CORS configuration for my storage:

What modifications should I make in my application to resolve this issue (the video is played as I receive the on-play-ended callback)?

        video.crossOrigin = "anonymous"

I am receiving the following error:

index.js:1 THREE.WebGLState: DOMException: Failed to execute 'texImage2D' on 'WebGL2RenderingContext': The video element contains cross-origin data, and may not be loaded.
    at Object.texImage2D (http://localhost:3000/static/js/vendors~main.chunk.js:339244:21)
    at uploadTexture (http://localhost:3000/static/js/vendors~main.chunk.js:340051:19)
    at WebGLTextures.setTexture2D (http://localhost:3000/static/js/vendors~main.chunk.js:339679:9)
    at SingleUniform.setValueT1 [as setValue] (http://localhost:3000/static/js/vendors~main.chunk.js:336186:12)
    at WebGLUniforms.upload (http://localhost:3000/static/js/vendors~main.chunk.js:336677:11)
    at setProgram (http://localhost:3000/static/js/vendors~main.chunk.js:343221:21)
    at WebGLRenderer.renderBufferDirect (http://localhost:3000/static/js/vendors~main.chunk.js:342547:21)
    at renderObject (http://localhost:3000/static/js/vendors~main.chunk.js:342939:13)
    at renderObjects (http://localhost:3000/static/js/vendors~main.chunk.js:342915:9)
    at renderScene (http://localhost:3000/static/js/vendors~main.chunk.js:342855:35)
    at WebGLRenderer.render (http://localhost:3000/static/js/vendors~main.chunk.js:342744:7)
    at World.draw (http://localhost:3000/static/js/main.chunk.js:4310:21)
    at World.step (http://localhost:3000/static/js/main.chunk.js:4318:14)
    at onAnimationFrame (http://localhost:3000/static/js/vendors~main.chunk.js:342661:35)
    at onAnimationFrame (http://localhost:3000/static/js/vendors~main.chunk.js:332519:5)

Answer №1

Big shoutout to jub0bs for helping me solve the issue - turns out the bug was in my CORS configuration.

The solution turned out to be including http:// before localhost:3000 instead of just using localhost:3000.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Are you transitioning from traditional scroll pagination to using ajax?

Is it possible to replace scroll pagination with ajax? I'm looking for an alternative to the large scroll pagination query and wondering if ajax could be used instead. Here is the current code snippet: feeds.scrollFeedPagination({ 'contentPage ...

Rewrite the nginx configuration to eliminate the "/index.html" part of the URL while preserving the query

My Nginx configuration specifies index index.html as the default index page. When accessing it as a progressive web app (using Angular), the URL loads as /index.html#/route instead of /#/route for some reason. I want to: Check if the URL contains ...

Is it possible to continuously loop and gradually fade the same image URL using JavaScript?

I have a dynamic image stored on my web server at example.com/webcam.jpg that is continuously updated by the server. My goal is to display this image on a static HTML page with a looping effect that smoothly transitions from the previous image to the upda ...

Prevent users from inserting images from their desktop into the HTML by disabling

While working on a HTML5 drag and drop image uploading feature, everything was going smoothly. I had a small div in the HTML with a JavaScript event handler set up like this: $('#uploader').on('dragover', function(e){ ... }).on(&apos ...

The HTML changes are not reflected in the document.querySelectorAll function

Trying to select all the div elements within another div using document.querySelectorAll. Interestingly, when setting the height to 1000 in the JS, the browser's scrollbar adjusts accordingly (the balloons do not change size). What could I be doing in ...

What is the method to conceal a certain element in jQuery based on the value of another element?

I am dealing with the following HTML structure: <button id="hideToggle">show/hide</button> <form id="item"> <div>Item 1 <input name="item1" type="number"/></div> <div>Item 2 <input name="item2" type="nu ...

Prevent scrolling on browser resize event

I am working on a basic script that adds a fixed class to a specific div (.filter-target) when the user scrolls beyond a certain point on the page. However, I am wondering how I can prevent the scroll event from triggering if the user resizes their brows ...

When tab switching occurs, the alert box fails to be processed by the browser

When using the alert(message) function, it will display an alert box with a message and an OK button. It will also pause the execution of any code that follows until the OK button is clicked. However, I have noticed a peculiar situation where switching tab ...

Using AngularJS to encapsulate an externally loaded asynchronous library as a service

Is there a way to wrap a 3rd party library that loads asynchronously into an Angular service? What is the best practice for incorporating such libraries as services in Angular? Currently, I am approaching it like this: angular.module('myAPIServices ...

The data input from the HTML is not being correctly transferred to the modal

I am trying to transfer the reservation id from an HTML element to a modal window. When I click "cancel" next to a reservation, a modal should appear showing the reservation id. However, the modal pops up without displaying the reservation id. Can anyone h ...

Retrieve the input field value without triggering the form submission

Is there a way to retrieve the current value of an input field, and then display information from a database based on that value without needing to submit a form? For example, imagine filling out a profile form and receiving an error message next to a fie ...

Make a request to the local API in a React Native mobile app by sending a GET request

Currently, I am working on a mobile application using React Native and utilizing SQL Server and NodeJS. The API for this project is located in my localhost. Upon running the application on an emulator, I encountered an issue when attempting to make a reque ...

Utilizing Vue's data variables to effectively link with methods and offer seamless functionality

I am encountering difficulty retrieving values from methods and parsing them to provide. How can I address this issue? methods: { onClickCategory: (value) => { return (this.catId = value); }, }, provide() { return { categor ...

The issue of the JQuery method failing to function properly on a button arises when the button is added

Upon loading a HTML page containing both HTML and JavaScript, the code is structured as shown below: <button id="test"> test button </button> <div id="result"></div> The accompanying script looks like this (with jQuery properly in ...

Creating a unique kendo ui widget from scratch

Is there a way to create a custom widget that functions similarly to the example shown in this sample: http://jsfiddle.net/anilca/u2HF7/ I found some helpful information here, but I'm struggling with defining dropdownlist templates and linking them ...

Remove nested comments using Ajax

I'm encountering a problem while attempting to delete my comments using Ajax. I believe I am on the right track but could use some guidance. Still in the process of familiarizing myself with jquery and similar technologies. While I can remove the comm ...

Tips for passing a page as an argument in the function parameter of the page.evaluate() method?

I keep running into this issue when I pass the page as an argument: TypeError: Converting circular structure to JSON --> commencing at object with constructor 'BrowserContext' | property '_browser' -> object with const ...

What could be the reason for the page scrolling upwards when clicking on href="#"?

I am encountering an issue with a hyperlink <a href="#" id="someID">Link</a> that is located further down the page. This link is used to trigger an Ajax request, but whenever it is clicked, the page automatically scrolls back to the top. I have ...

Exploring nested arrays with recursive looping

I have been working on solving this challenge using recursion because I enjoy the challenge. The task at hand involves taking an array of arrays and transforming it into a single array with all the values combined. While I have made good progress, I am e ...

Best practices for starting and stopping trace spans in express / nodejs applications

Currently, I am conducting an experiment with utilizing the Opentelemetry.js nodejs/express library and attempting to refactor the reviews application from the bookinfo Example found in Istio. I followed the tracer configurations laid out in the sample: ...