How to customize the content of video request header when web loads video?

Corporate video needs to be encrypted. This can be achieved by adding a string of token-like data to the header of the HTTP request for video data at the front end, so as to determine whether the video data is allowed to be returned at the backend. Both iOS and Android have a way to set the video request header, and how to implement the frontend? I currently use the video.js player, but I can"t find a way to set the request header. Ask for help!


tags like video and img do not seem to set the request header.


const xhr = new XMLHttpRequest();
xhr.onreadystatechange = function(){
    if(this.readyState === 4){
        if (this.status === 200){
            const res = this.response || this.responseText;
            // type 
            const blob = new Blob([res],{type:"video/mp4"});
            const blobUrl = URL.createObjectURL(blob);
            document.querySelector("video").src = blobUrl;
        }
    }
};
xhr.open("get", "", true);
//
xhr.setRequestHeader("key","value");
//
xhr.setRequestHeader("token","abcdefg");
xhr.setRequestHeader("haha","lala");
//
xhr.send();

have you solved


how to solve this problem at that time, my request header can not be set, I changed it. It's been a long time

Menu