Closed peter-pr closed 3 years ago
If you read in the browser console you should get something the CORS
, unfortunately, there is nothing we can do to fix this issues, since requests with a different origin then the webpage one are automatically blocked.
The only way to workaround this issue would be to implement a custom http client that acts as a middleware and redirects instead the requests a server of yours (maybe see https://github.com/Rob--W/cors-anywhere )and then to the youtube api.
This might not be a trivial task to do if you don't know where to look for, and have not prior experiences implementing custom http clients and this kind of stuff.
ok thanks for clarification. So this means https://pub.dev/packages/youtube_explode_dart does not support "web". The package compatibility information is misleading.
I cannot change that, since the package can be compiled in web, the thing is that then the requests cannot be successfully made to the youtube endpoint
@Hexer10, just out of interest, have you tried to use embed youtube URLs?
So instead of https://www.youtube.com/watch?v=cP5fnXQfaao => https://www.youtube.com/embed/cP5fnXQfaao
@M123-dev That is already implemented in the library, first the data is fetched from the watchpage, and if that fails from the embed page
Using middleware like https://cors-anywhere.herokuapp.com , that you said, works in flutterweb, but you need to modify the code in search_page, for add it when get 'https://www.youtube.com/results?search..'.
something like that:
static Future
thanks for the package! ^_^
But is it not just possible to add header to your get request to allow cross origins ?
header("Access-Control-Allow-Origin: *");
https://fluttercorner.com/flutter-web-getting-xmlhttprequest-error-while-making-http-call/
Describe the bug The library cannot send requests in flutter web.
Stacktrace: