WARNING: sanitizing unsafe URL value cdvfile:

Hi

I’ am getting this error on android but on ios

unsafe:cdvfile://localhost/persistent/50.jpg
Failed to load resource: the server responded with a status of 404 (Not Found)

config.xml has

For ionic 2 rc After a long day of searching Here comes the solution


copied here
For anyone experiencing this issue, I have ‘solved’ it by using the following:

Class:

import {DomSanitizer} from ‘@angular/platform-browser’;

constructor(private DomSanitizer: DomSanitizationService) {}
Template:

<img [src]=“DomSanitizer.bypassSecurityTrustUrl(imgSrcProperty)”/>

Where imgSrcProperty is the offending image base64 encoded.

1 Like

Now:
constructor(private domSanitizer: DomSanitizer) {}

Also I just realized that I was using tags rather than if you use ion-img it sanitizes for you so this is not necessary.