DeanB_Develop
DeanB_Develop

Reputation: 2137

JSPM + Cordova + Android

I get the following error when using JSPM CDN JavaScript, Cordova 5.1.1, TypeScript and Android:

Failed to load resource: the server responded with a status of 404 (Not Found) [email protected] (0,0)

enter image description here

I took the default VS2015 TypeScript Cordova project and added the following to index.html: <script src="https://jspm.io/[email protected]"></script>

The sample code has been tested on Windows Phone and works. I have tried Android API 19 and 22, physical devices and Genymotion(emulator). Domain Access URI has been set to *.

Any ideas on why this would be happening only on Android devices?

Upvotes: 0

Views: 313

Answers (1)

DeanB_Develop
DeanB_Develop

Reputation: 2137

Found the problem. Here's the fix:

Add the custom plugin cordova-plugin-whitelist to the project. It can be downloaded here https://www.npmjs.com/package/cordova-plugin-whitelist

I also had to add the following code to the <head> tag in index.html.

<meta http-equiv="Content-Security-Policy" content="default-src https: 'self' jspm.io; script-src 'self' 'unsafe-inline' https://jspm.io">

If there's a better approach, please add an answer.

Upvotes: 0

Related Questions