Content-Security-Policy with Ionic and Socket.IO
<p>I need to use a socket.io connection in my ionic2 app.</p>

<p>I installed socket.io-client via npm so i can use it like this.</p>

<pre><code>import * as io from 'socket.io-client'
...
...
this.socket = io(this.conf.connectionServer);
this.socket.on('connect', () =&gt;{
...
...})
</code></pre>

<p>I does work when i'm using <code>ionic serve</code> in chrome or when running ionic <code>run -l</code>
but when i just <code>build</code> or <code>run</code> everything with ionic run it won't work. </p>

<p>i was able to log the error messsge on the screen of my android-device: </p>

<pre><code>Error: Failed to execute: open: on :XMLHttpRequest:: Refused to connect to : http://file/socket.io/?EIO.....: because it violates the documents Content Security Policy.....
</code></pre>

<p>My Content Security Policy is:</p>

<pre><code>&lt;meta http-equiv="Content-Security-Policy" 
    content="default-src 'self';                                                                                                                                ;
        style-src 'self' 'unsafe-inline'; 
        script-src 'self' 'unsafe-inline' 'unsafe-eval'
                    http://localhost:*
                    http://127.0.0.1:*

                    ;
        connect-src 'self'
                    ws://*
                    http://141.xx.xx.25:*
                    http://*.foobar.de
                    http://file/socket.io*
                    ;

        img-src *;
        media-src *
    "&gt;
</code></pre>

<p>But i cant find the right solution.I</p>

<p>In Chrome the connection goes to: <a href="http://141.XX.XX.25/socket.io/" rel="nofollow">http://141.XX.XX.25/socket.io/</a>
but on android it trys to connect to <a href="http://file/socket.io/" rel="nofollow">http://file/socket.io/</a></p>

<p><strong>Even if I set it to  <code>default-src *;</code> the Socket.io-Connection will only work when using <code>Serve</code> or <code>run with the Livereload-option</code></strong></p>

<p>I'm using:</p>

<pre><code>Cordova CLI: 6.0.0
Gulp version: CLI version 3.9.1
Gulp local:
Ionic Version: 2.0.0-beta.1
Ionic CLI Version: 2.0.0-beta.17
Ionic App Lib Version: 2.0.0-beta.8
OS:
Node Version: v5.6.0
</code></pre>