I can’t seem to get ionic (v1.0.1) to issue a cross origin request to my server running nginx. Just using curl to see what the options request looks like shows the Access-Control-Allow-Origin and other headers are coming across properly:
curl -i -X OPTIONS www.devapp.com/myroute/ HTTP/1.1 200 OK Server: nginx/1.8.0 Date: Wed, 08 Jul 2015 13:37:08 GMT Content-Type: text/html; charset=utf-8 Content-Length: 0 Connection: keep-alive Allow: HEAD, OPTIONS, GET Access-Control-Allow-Origin: * Access-Control-Allow-Methods: OPTIONS,GET,PUT,POST,DELETE Access-Control-Allow-Headers: X-FirePHP-Version,Accept,Origin,Referer,User-Agent,Content-Type
However, when debugging when the app is on my device using livereload, i.e.
ionic run android -l -c
I can’t make any requests to the server, and I’m getting cross-origin errors:
XMLHttpRequest cannot load http://www.devapp.com/myroute/. Origin http://192.168.1.14:8100 is not allowed by Access-Control-Allow-Origin.
I’m not seeing any OPTIONS requests pre-flighted before the actual request is made either. Any idea how to fix this?