2 years ago

#31794

test-img

Aamer Alturi

Why youtube-dl u3m8 to react js get (cors error)

I have a site that shows a live broadcast from youtube Website built from reactjs and nodejs In frontend I use video.js and hls.js, to view a live broadcast from M3U8 links, and it works for me with a sample link: https://multiplatformf.akamaihd.net/i/multi/will/bunny/big_buck_bunny_,640x360_400,640x360_700,640x360_1000,950x540_1500,.f4v.csmil/master.m3u8 In nodejs (backEnd) I use youtube-dl model to create or get an M3U8 link, I send it to react and put it in the src value in video html tag.

react component code:

let videoSrc = data.url;
if (Hls.isSupported()) {
    var hls = new Hls();
    hls.loadSource(videoSrc);
    hls.attachMedia(video);
}

node js code:

let video = youtubedl(`yotubeUrl`, [])
let stream = this;
video.on('info', function (info) {
    console.log(info.url)
    stream.updateYoutubeStream(info.url) // personal function to update m3u8 url
}).on('error', err => {
    console.log(err)
})

But he gives me a cors error enter image description here And unable to connect with me What is the problem? And how can it be fixed?

Thank you very much

node.js

reactjs

video-streaming

youtube-dl

hls.js

0 Answers

Your Answer

Accepted video resources