ionic-image-loader icon indicating copy to clipboard operation
ionic-image-loader copied to clipboard

CORS problem in Android device

Open javgueram opened this issue 7 years ago • 10 comments

Hi, I am trying to use this plugin to download and cache some images (each and every image is showned every second, as a forecast map). In my web browser Chrome works perfectly, but when I install the app on a real android device I could see trought logcat I am getting CORS blocking

Access to XMLHttpRequest at '<MY_URL_TO_THE_IMAGE>' from origin 'http://localhost:8080' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Some help? Thanks

javgueram avatar Dec 18 '18 12:12 javgueram

I experience a similar problem. It seems like the ionic 4 compatible version displays the image but isn't capable of storing them in the cache. Some devs mentioned that the IonicWebView has problems since 4.2.1 and blocks CORS.

cluigDE avatar Jan 03 '19 14:01 cluigDE

Hello, I'm facing the same problem... Did you solve it?

alessandro-candon avatar Jan 08 '19 10:01 alessandro-candon

As far as I know the only solution might be the following: Own the server you receive the data from and set up ACAO for whatever you need. https://enable-cors.org/ That's at least how I solved this.

cluigDE avatar Jan 08 '19 13:01 cluigDE

uff, it is a so big limit, because it isn't my server where are stored the images...

alessandro-candon avatar Jan 08 '19 13:01 alessandro-candon

am using aws s3 bucket it worked on ios perfectly now but on android i dont receive any errors but the images never shown please if its a cors thing can u change the code to use ionicnative http and ditch the angular http since ionic native provide a proxy which solves this problem

warbadev avatar Jan 22 '19 15:01 warbadev

I'm using AWS S3 bucket and was facing the same CORS problem when I updated the ionic cordova webview to V2+. To solve this, just configure the CORS in the Amazon console like this:

https://docs.aws.amazon.com/AmazonS3/latest/dev/cors.html

pcsantana avatar Mar 30 '19 16:03 pcsantana

@pcsantana I'm using my own server, what should I do? It's two days that I'm searching but didn't make it yet. I think the plugin needs some debugging on ionic4

khsed14 avatar Jul 24 '19 10:07 khsed14

Hi @khsed14 sorry for delay!

I did not tried yet this plugin with ionic 4, but you should implement a CORS filter in your backend. (e.g. in Java).

Also, ionic team makes some considerations here.

This plugin has too a branch for Ionic v4. You can try to use it: https://github.com/zyra/ionic-image-loader/tree/v4

Holpe it helps!

pcsantana avatar Jul 29 '19 12:07 pcsantana

iam facing the similar issue on device but also facing CORS issue with firebase ? any solutions

aditbharadwaj avatar Aug 04 '19 17:08 aditbharadwaj

I‘m facing this issue with iOS and CloudFront in combination with S3... I configured CORS on S3 and forward the Headers in CloudFront.

Anyone else having this problem or did solve it?

EDIT: Seems to be my own fault. As described on #277 the cache cleaning is not working for me so I deleted the folders manually. This seems to break down the plugin and causes CORS issues. If I reinstall the App, everything is working fine again til I delete the folders again :)

Bart1909 avatar Feb 06 '20 19:02 Bart1909