destruc7i0n / nani

Crunchyroll without the bloat
https://nani.ninja
MIT License
71 stars 10 forks source link

CORS policy errors #30

Closed zlmonroe closed 3 years ago

zlmonroe commented 4 years ago

Looks like none of the videos are working. There seems to be a decent amount of CORS policy related errors.

image

zlmonroe commented 4 years ago

Hmmm, I just saw your recent commits adding the CORS proxy. I checked the source on the page I had loaded - it definitely has the proxy added to api.allorigins.win

destruc7i0n commented 4 years ago

Seems like CR is now adding the cors to more internal urls, I just pushed a small fix to automatically proxy those requests as well :)

destruc7i0n commented 4 years ago

I probably should have not closed this issue so fast, been getting messages regarding it not working. @zlmonroe can you say if it’s working for you?

zlmonroe commented 4 years ago

The videos have been playing fine. Just confirmed from my phone that they still are as well. I can check later today more thoroughly though and see if any less obvious CORS are thrown from other resources if it helps.

Update: Nothing on my side. Went through the queue, recent, series lists, etc. and it seems fine for me.

zlmonroe commented 4 years ago

image I stand corrected...

zlmonroe commented 4 years ago

image

It seems that the videos sort of work, but I am sometimes getting issues. I am also getting some "buffer stalled" type issues now which may be related (slowdown from the proxy?).

destruc7i0n commented 4 years ago

That one time that you got CORS may have been from some sort of downtime? Their downtime page has CORS enabled. Which video did you get this hls error? Could not seem to replicate from randomly navigating around videos.

zlmonroe commented 4 years ago

It's definitely possible. Those two were from two different videos if I recall correctly. Don't remember the first, but the second was whatever the newest english dub of "Misfit of Demon Academy" is because I changed to the most recent video to test if it was just the first video.

I am not having the problem now though. Honestly if I was thinking, I should have copied the error details and not just screenshotted. The URL probably would have helped to determine the resource a bit more... sorry about that lol. If I get something again I will try to copy the dump.

As a note, I wonder if it wouldn't be too hard to create a generic retry policy on all XHR requests. I know it is impossible to detect CORS errors from javascript, but theoretically it should just show as a network failure right? I don't know if the player API has any way to wrap/replace the XHR object or anything like that though? It might be useful for dealing with Crunchyroll increasing their security if any request tries without the proxy and can automatically retry with upon failure. Worst case is something didn't actually need the proxy but adds it anyways.

destruc7i0n commented 4 years ago

Yeah the current authentication system really needs to be rewritten at some point, as when I initially made it I didn't expect for all of this stuff which happens quite often these days. The initial reload if you load up the page after not visiting for a few days is due to it refreshing the token (there is not a good in-place method of doing it apart from reloading everything!). Time is a little tight for me right now, though. Will be a while until I can do a large refactor like that for this project, sadly