KDeogharkar
KDeogharkar

Reputation: 10959

How to add Content Security Policy in index.html

I am developing application in Ionic and when I run this application in iOS device it stucks on splashscreen for sometime and then it load.I check console and there it shows that device ready is fired after 95245 ms . That means device is taking too much time to being ready.

I search for the issue and find similar issue here and for that accepted solution is like below:


As Louis Suggest

I added Thanks for your response @baviskarmitesh. But I had to add gap to the content security policy and now it seems to work.

I added data: gap: https://ssl.gstatic.com 'unsafe-eval'after default-src * into my content security policy in my index.html file, like this:

meta http-equiv="Content-Security-Policy" content=" default-src * data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; script-src 'self' 'unsafe-inline' 'unsafe-eval' *; connect-src 'self' 'unsafe-inline' 'unsafe-eval' blob: ws: *; "> And now deviceready fires quickly with all my plugins.

Now I am trying to pass this meta tag for Content-Security-Policy in my index.html but whenever I build my iOS app using this command.

ionic cordova build ios

This Content-Security-Policy meta tag is remove automatically from my index.html. So how can I add this Content-Security-Policy in my index.html? Is there any other way ?

Upvotes: 4

Views: 1921

Answers (1)

jcesarmobile
jcesarmobile

Reputation: 53301

Make sure you are doing the changes on the index.html file that is inside the src folder.

When you run ionic cordova build ios, it generates the www folder with the src content and Cordova uses the www folder content to build the app.

Upvotes: 3

Related Questions