Cordova-plugin-ionic-webview: Not allowed to load local resource

Created on 3 Sep 2018  路  9Comments  路  Source: ionic-team/cordova-plugin-ionic-webview

Hi there,
I am having problems wit the new webview version plugin.
I am using:
ionic-image-loader
from:
https://github.com/zyra/ionic-image-loader

and
angular-cropperjs
from
https://github.com/matheusdavidson/angular-cropperjs

Trying to show local images.

And in both I get this error:
Not allowed to load local resource

When downgrading back to: 1.2.1 all is working.

What can be the problem?

Most helpful comment

The new webview doesn't allow file:// urls, you have to convert them to localhost urls with convertFileSrc function

All 9 comments

I have the exact same issue with "Not allowed to load local resource" when using camera.getPicture. I can take a photo with the camera, it lets me crop it, then does not display it. Same if I choose from a photo library. The console showed that the filename it was trying to load was incorrectly formatted, sorry, I did not screenshot. Downgrading to 1.2.1 also fixed this for me.

Are they file:// urls or are you using convertFileSrc function to make them http://localhost:port/ urls?

They are file:// urls

The new webview doesn't allow file:// urls, you have to convert them to localhost urls with convertFileSrc function

Add ngx to the import: @ionic-native/ionic-webview/ngx we really need to fix this.

Also this isn鈥檛 relevant to the original issue

Not sure why it was reopened, but using the @ionic-native/ionic-webview's convertFileSrc function it works.

More info:
https://beta.ionicframework.com/docs/native/ionic-webview/

I don't know why but my app is not even showing anymore now... it's all white after using/updating ionic-webview.

Oops, my bad, I forgot to register Webview at app.module.ts. =X

Indeed convertFileSrc is the way of fixing this. <3 Thank you!

how

Oops, my bad, I forgot to register Webview at app.module.ts. =X

Indeed convertFileSrc is the way of fixing this. <3 Thank you!

how you register Webview in app.module.ts

Was this page helpful?
0 / 5 - 0 ratings

Related issues

50l3r picture 50l3r  路  7Comments

mowaiskalam picture mowaiskalam  路  6Comments

peterpeterparker picture peterpeterparker  路  6Comments

FarhadG picture FarhadG  路  6Comments

paulstelzer picture paulstelzer  路  8Comments