title: ionic app cannot connect cors enabled server with $http
body: <p>I am trying to build a mobile app with ionic framework. When my application tries to connect  server to get json ( server is web api and cors is enabled)  it just returns 404 on genymotion and real device. But when I run application in browser with <code>ionic serve</code> everything work fine. </p>
  
  <p>I am pretty sure CORS is functional. Here response header I got while application working in browser.</p>
  
  <p><strong>Response</strong></p>
  
  <pre><code>Access-Control-Allow-Origin:*
  Cache-Control:no-cache
  Content-Length:395
  Content-Type:application/json; charset=utf-8
  Date:Fri, 08 May 2015 20:24:04 GMT
  Expires:-1
  Pragma:no-cache
  Server:Microsoft-IIS/7.0
  X-AspNet-Version:4.0.30319
  X-Powered-By:ASP.NET
  </code></pre>
  
  <p><strong>Request</strong> : </p>
  
  <pre><code>Accept:application/json, text/plain, */*
  Accept-Encoding:gzip, deflate, lzma, sdch
  Accept-Language:tr-TR,tr;q=0.8,en-US;q=0.6,en;q=0.4
  Cache-Control:no-cache
  Connection:keep-alive
  DNT:1
  Host:*******:14400
  Origin:http://192.168.0.28:8100
  Pragma:no-cache
  Referer:http://192.168.0.28:8100/
  </code></pre>
  
  <p>Config.xml has  <code>&lt;access origin="*"/&gt;</code> this line in configuration</p>
  
  <p>in my app.js I removed X-Requested-With headers for all http calls.</p>
  
  <pre><code>.config(['$httpProvider', function($httpProvider) {
  
          $httpProvider.defaults.useXDomain = true;
          delete $httpProvider.defaults.headers.common['X-Requested-With'];  
      }
  ])
  </code></pre>
  
  <p>I simple use get requests to server in my factory classes.</p>
  
  <pre><code>$http.get(serverPath + "/api/mobilerest/mainPage");
  </code></pre>
  
  <p>When I run application in Genymode or real device, response is 404 and statusText is 'not found'. I am pretty sure web api is working, the cause for this behaviour is in ionic based apps, my app is local file and protocol  is file:/// so Origin header is null the in request, then server returns 404. I also tried a local file without any server I get the same error like in application.</p>
  
  <pre><code>Accept:*/*
  Accept-Encoding:gzip, deflate, sdch
  Accept-Language:tr-TR,tr;q=0.8,en-US;q=0.6,en;q=0.4
  Cache-Control:no-cache
  Connection:keep-alive
  DNT:1
  Host:server:14400
  Origin:null
  Pragma:no-cache
  </code></pre>
  
  <p>Am I missing something ?</p>