api.consumet.org icon indicating copy to clipboard operation
api.consumet.org copied to clipboard

HLS Cors error

Open dishant0406 opened this issue 1 year ago • 22 comments

Describe the bug

I am using the streaming link that is provided by the api in the format of .m3u8 on my frontend using hls.js but it gives cors error and I am unable to play the video is there any way to solve or bypass the cors issue

Steps to reproduce

  1. Fetch the steaming link of which anime you want to watch
  2. Using Plyr-React with hls.js to show the video

Expected behavior

The video should play

Actual behavior

Showing cors error

Additional context

No response

dishant0406 avatar Mar 13 '23 14:03 dishant0406

You could use a CORS proxy

SlideMovies avatar Mar 19 '23 18:03 SlideMovies

Hi @SlideMovies If possible, can you please help me how to use or setup the proxy on the frontend or the backend or you can provide any documentation sort off.

dishant0406 avatar Mar 19 '23 18:03 dishant0406

@dishant0406 Sure, you can email me at [email protected]

SlideMovies avatar Mar 20 '23 11:03 SlideMovies

I also came across this error while using React-player can anyone please help me out how to resolve this.

Anuragkumarsah avatar Mar 27 '23 04:03 Anuragkumarsah

I get this error too,I need help,thanks very much.

vuasancoggo222 avatar Mar 27 '23 09:03 vuasancoggo222

I get this error too,I need help,thanks very much.

I found a way around to handle this you can use this url and paste the video url directly after this as path parameter and it will work. "https://corsanywhere.herokuapp.com/"

Anuragkumarsah avatar Mar 27 '23 11:03 Anuragkumarsah

@Anuragkumarsah It worked, thank you very much.

vuasancoggo222 avatar Mar 28 '23 04:03 vuasancoggo222

I get this error too,I need help,thanks very much.

I found a way around to handle this you can use this url and paste the video url directly after this as path parameter and it will work. "https://corsanywhere.herokuapp.com/"

Arent there any rate limit

Shuvadip-Ghosh avatar Mar 28 '23 11:03 Shuvadip-Ghosh

I get this error too,I need help,thanks very much.

I found a way around to handle this you can use this url and paste the video url directly after this as path parameter and it will work. "https://corsanywhere.herokuapp.com/"

Arent there any rate limit

Yeah there is a rate limit of 50 request per minute, as far as I remember.

Anuragkumarsah avatar Mar 28 '23 11:03 Anuragkumarsah

I get this error too,I need help,thanks very much.

I found a way around to handle this you can use this url and paste the video url directly after this as path parameter and it will work. "https://corsanywhere.herokuapp.com/"

@Anuragkumarsah can you please share an example - I tried - fetch("https://api.consumet.org/anime/gogoanime/watch/spy-x-family-episode-1") .then((response) => response.json()) .then((result) => console.log(result));

result = { "headers": { "Referer": "https://anihdplay.com/embedplus?id=MTg0MTQx&token=1ctpyL9t_G4C-tgO1FKYnA&expires=1680290342" }, "sources": [ { "url": "https://tc-002.adesicdn.com/1ab5d45273a9183bebb58eb74d5722d8ea6384f350caf008f08cf018f1f0566d0cb82a2a799830d1af97cd3f4b6a9a81ef3aed2fb783292b1abcf1b8560a1d1aa308008b88420298522a9f761e5aa1024fbe74e5aa853cfc933cd1219327d1232e91847a185021b184c027f97ae732b3708ee6beb80ba5db6628ced43f1196fe/0789fd4f049c3ca2a49b860ea5d1f456/ep.1.1677591537.360.m3u8", "isM3U8": true, "quality": "360p" }, { "url": "https://tc-002.adesicdn.com/1ab5d45273a9183bebb58eb74d5722d8ea6384f350caf008f08cf018f1f0566d0cb82a2a799830d1af97cd3f4b6a9a81ef3aed2fb783292b1abcf1b8560a1d1aa308008b88420298522a9f761e5aa1024fbe74e5aa853cfc933cd1219327d1232e91847a185021b184c027f97ae732b3708ee6beb80ba5db6628ced43f1196fe/0789fd4f049c3ca2a49b860ea5d1f456/ep.1.1677591537.480.m3u8", "isM3U8": true, "quality": "480p" }, { "url": "https://tc-002.adesicdn.com/1ab5d45273a9183bebb58eb74d5722d8ea6384f350caf008f08cf018f1f0566d0cb82a2a799830d1af97cd3f4b6a9a81ef3aed2fb783292b1abcf1b8560a1d1aa308008b88420298522a9f761e5aa1024fbe74e5aa853cfc933cd1219327d1232e91847a185021b184c027f97ae732b3708ee6beb80ba5db6628ced43f1196fe/0789fd4f049c3ca2a49b860ea5d1f456/ep.1.1677591537.720.m3u8", "isM3U8": true, "quality": "720p" }, { "url": "https://tc-002.adesicdn.com/1ab5d45273a9183bebb58eb74d5722d8ea6384f350caf008f08cf018f1f0566d0cb82a2a799830d1af97cd3f4b6a9a81ef3aed2fb783292b1abcf1b8560a1d1aa308008b88420298522a9f761e5aa1024fbe74e5aa853cfc933cd1219327d1232e91847a185021b184c027f97ae732b3708ee6beb80ba5db6628ced43f1196fe/0789fd4f049c3ca2a49b860ea5d1f456/ep.1.1677591537.1080.m3u8", "isM3U8": true, "quality": "1080p" }, { "url": "https://tc-002.adesicdn.com/1ab5d45273a9183bebb58eb74d5722d8ea6384f350caf008f08cf018f1f0566d0cb82a2a799830d1af97cd3f4b6a9a81ef3aed2fb783292b1abcf1b8560a1d1aa308008b88420298522a9f761e5aa1024fbe74e5aa853cfc933cd1219327d1232e91847a185021b184c027f97ae732b3708ee6beb80ba5db6628ced43f1196fe/0789fd4f049c3ca2a49b860ea5d1f456/ep.1.1677591537.m3u8", "isM3U8": true, "quality": "default" }, { "url": "https://www002.anifastcdn.info/videos/hls/_PK_JUqGrakYdO8LcdTdMg/1680297543/184141/0789fd4f049c3ca2a49b860ea5d1f456/ep.1.1677591537.m3u8", "isM3U8": true, "quality": "backup" } ], "download": "https://gogohd.net/download?id=MTg0MTQx&token=1ctpyL9t_G4C-tgO1FKYnA&expires=1680290342" }

I'm making the url as https://corsanywhere.herokuapp.com/?path=https://tc-002.adesicdn.com/1ab5d45273a9183bebb58eb74d5722d8ea6384f350caf008f08cf018f1f0566d0cb82a2a799830d1af97cd3f4b6a9a81ef3aed2fb783292b1abcf1b8560a1d1aa308008b88420298522a9f761e5aa1024fbe74e5aa853cfc933cd1219327d1232e91847a185021b184c027f97ae732b3708ee6beb80ba5db6628ced43f1196fe/0789fd4f049c3ca2a49b860ea5d1f456/ep.1.1677591537.360.m3u8 Also tried zoho links. It's not working.

singh-jay avatar Mar 31 '23 17:03 singh-jay

You need to give the url directly after slash path parameter is not need Like - https://corsanywhere.herokuapp.com/https://tc-002.adesicdn.com/1ab5d45273a9183bebb58eb74d5722d8ea6384f350caf008f08cf018f1f0566d0cb82a2a799830d1af97cd3f4b6a9a81ef3aed2fb783292b1abcf1b8560a1d1aa308008b88420298522a9f761e5aa1024fbe74e5aa853cfc933cd1219327d1232e91847a185021b184c027f97ae732b3708ee6beb80ba5db6628ced43f1196fe/0789fd4f049c3ca2a49b860ea5d1f456/ep.1.1677591537.360.m3u8

H4jw avatar Mar 31 '23 17:03 H4jw

It says, Missing required request header. Must specify one of: origin,x-requested-with

shrkwt avatar Apr 02 '23 12:04 shrkwt

If you directly follow the link in browser it shows Missing required request header. Must specify one of: origin,x-requested-with

But if you fetch the link form browser it works, cors_github_solution_answer

H4jw avatar Apr 02 '23 14:04 H4jw

Now again it is not working, I guess, I am again getting Cors error, even with corsanywhere.

Anuragkumarsah avatar Apr 07 '23 07:04 Anuragkumarsah

Now again it is not working, I guess, I am again getting Cors error, even with corsanywhere.

But it's working for me

H4jw avatar Apr 07 '23 12:04 H4jw

Now again it is not working, I guess, I am again getting Cors error, even with corsanywhere.

But it's working for me

image

It is showing Cors error to me though.

Anuragkumarsah avatar Apr 10 '23 04:04 Anuragkumarsah

Ok nvm, I think this was a problem from corsanywhere, I used "https://cors.zimjs.com/" and now it is working again.

Anuragkumarsah avatar Apr 10 '23 05:04 Anuragkumarsah

Ok nvm, I think this was a problem from corsanywhere, I used "https://cors.zimjs.com/" and now it is working again.

hello bro, i have tried using different hls player to play an episode m3u8 link from https://api.consumet.org/anime/zoro/watch?episodeId=tokyo-revengers-15585$episode$64630$both, but none of them worked only jwplayer worked i think its using some unique cors policy or something, can you please help me out, ive tried to run my code on replit it didnt worked, but when i downloaded replit on my mobile and ran it again the video started to play

IrfanKhan66 avatar Apr 13 '23 16:04 IrfanKhan66

I guess, Replit code of yours is being prevented by Cors Policy to fetch the HLS(.m3u8) manifest and play it.

Whereas, the Replit app on mobile devices might has its own browsing environment that might not have Cors Policy.

Well, talking about JWPlayer; Take a look at https://anihdplay.com/embedplus?id=MTY2NDQ4&token=rTS6SSjXPKJJoby90ft--Q&expires=1681475515

This link is the same as provided by API as referrer for a request at, https://api.consumet.org/anime/gogoanime/watch/dororo-dub-episode-1

Notice that the Referrer links have just the same JWPlayer in them. So, it clarifies that the Anime HLS videos from GOGO are specifically meant to be played on JWPlayer as per the Cors Policy.

Here, a cors proxy should be used to use any other player to play on any browser (as each browser has Cors Proxy for security).

shrkwt avatar Apr 14 '23 10:04 shrkwt

I think that the same goes for Zoro also.

shrkwt avatar Apr 14 '23 10:04 shrkwt

I think that the same goes for Zoro also.

i solved the cors error, but im still having one issue, when i fetch animes from zoro provider then in the subordub field i only get to see sub

IrfanKhan66 avatar Apr 23 '23 06:04 IrfanKhan66

guys if i created my own instance of jwplayer to avoid cors will it work? If yes, then what will be configuration we have to pass, if no whats the better solution to handle it.

saurabhgangule avatar Jun 02 '23 04:06 saurabhgangule