barsh
barsh

Reputation: 471

How to load cordova.js from a remote website?

I know this is a terrible idea, but I have an app that navigates to a website and then loads cordova.js using

<script src="cdvfile://localhost/persistent/cordova.js" />

But this doesn't seem to work anymore.

Upvotes: 3

Views: 2739

Answers (3)

XDev 2381
XDev 2381

Reputation: 11

There is an defect open, Please check the comment https://github.com/apache/cordova-plugin-file/issues/347#issuecomment-545971964

Upvotes: 1

Guy L.
Guy L.

Reputation: 163

For android: Disable mixed content policy using: https://developer.android.com/reference/android/webkit/WebSettings.html#MIXED_CONTENT_ALWAYS_ALLOW)

For ios: I submitted a PR to the file plugin which solves the mixed content problem on ios: apache/cordova-plugin-file#296 The fixed version is available at: https://github.com/guylando/cordova-plugin-file If you load a remote site https://example.com on the webview then it allows to access local files using the url: https://example.com/cdvfile/bundle/www/cordova.js instead of cdvfile://localhost/bundle/www/cordova.js And by this solves the mixed content problems

Upvotes: 0

barsh
barsh

Reputation: 471

Would you know it... after hours and hours, as soon as I post to StackOverflow, I figured it out.

<script src="cdvfile://localhost/bundle/www/cordova.js" />

(at least for iOS, can't speak for Android)

Upvotes: 1

Related Questions