Content-security-policy refused to load image


#1

Hi,

I realise this is not completely Ionic related but I’m wondering if anyone can help me out here as I’m going slightly crazy.

I am using ng-file-upload to allow the user to select an image or video from their phone. However I keep getting the following error. No combination of content-security-policy entries seems to work apart from if I add ‘*’ to image-src and connect-src

Error:
Refused to load the image ‘blob:null/eca5cf55-4440-4ddc-8fcb-94cca13ac663’ because it violates the following Content Security Policy directive: “img-src ‘self’ https: blob: data:”.

CSP:
content=“default-src * gap:; object-src ‘self’ blob:; connect-src ‘self’ blob: wss: https:///; img-src ‘self’ https: blob: data:; style-src ‘self’ ‘unsafe-inline’; script-src ‘self’ ‘unsafe-inline’”

If anyone can help I would be very appreciative.

Thanks


#2

Hello, did you managed to fix this? I am having the same problem.


#3

To be honest, I completely forgot about this. I think I managed to fix it but cannot directly see what I did. Perhaps if you could post your CSP I could take a look through and see if anything jogs my memory. I can see that I upgraded my cordova-ios (4.1.1) and cordova-android (5.1.1) platforms. Not sure if that is linked.


#4

I finally fix it adding img-src 'self' blob: to my <meta http-equiv="Content-Security-Policy"> tag in index.html


#5

Glad to hear you fixed it. I have ‘self’ in there as well. It’s just one of those annoying things.


#6

Yes, I have that too.
Hopefully this thread will help others too!