rohit-chouhan / youtube-flutter

A package to stream/download youtube video or thumbnail and more.
https://pub.dev/packages/youtube
MIT License
6 stars 2 forks source link

Any solutions for CORS issues while using this tool in flutter web? #2

Closed mlars84 closed 3 months ago

mlars84 commented 1 year ago

The following code:

Image.network(
  YoutubeThumbnail(youtubeId: <ID>).hd(),
)

throws:

The following ImageCodecException was thrown resolving an image codec:
Failed to load network image.
Image URL: https://img.youtube.com/vi/JIQic86AiuQ/hqdefault.jpg
Trying to load an image from another domain? Find answers at:
https://flutter.dev/docs/development/platform-integration/web-images
When the exception was thrown, this was the stack
Image provider: NetworkImage("https://img.youtube.com/vi/<ID>/hqdefault.jpg", scale: 1)
Image key: NetworkImage("https://img.youtube.com/vi/<ID>/hqdefault.jpg", scale: 1)

Is there a way around this. I could store the image in my firebase storage to bypass the CORS issue, but then obviously there will be no way to download or play the actual video.

themattman18 commented 11 months ago

There seems to be a lot of issues with Flutter web and cors. I found a Stack Overflow post which said to launch my app using the command flutter run -d chrome --web-renderer html // to run the app and to build it with flutter build web --web-renderer html --release // to generate a production build

https://stackoverflow.com/questions/65653801/flutter-web-cant-load-network-image-from-another-domain

rohit-chouhan commented 3 months ago

new version released