I'm tring to GET from a api system with angular $http.get module but :
api endpoint system just accept GET method and won't work with OPTION method
REQUEST headers :
Host: www.example.com
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Access-Control-Request-Method: GET
Access-Control-Request-Headers: x-device-type,x-software-version,x-unit-measurement
Origin: http://localhost:3000
Connection: keep-alive
RESPONSE headers:
Status code: 405 Method Not Allowed
Access-Control-Allow-Headers: Content-Type, Accept, origin, referring-domain, X-UNIT-MEASUREMENT, X-AUTH-TOKEN, X-DEVICE-TYPE, X-SOFTWARE-VERSION
Access-Control-Request-Method: GET, POST, PUT, DELETE, OPTIONS
Allow: GET
Cache-Control: private,no-transform
Content-Length: 1565
Content-Type: text/html; charset=UTF-8
Date: Thu, 14 Apr 2016 11:41:13 GMT
Server: Microsoft-IIS/8.5
X-API-VERSION: 1.40.1.0
X-INSTANCE-ID: ALL
X-Powered-By: ASP.NET
access-control-allow-credentials: true
access-control-allow-origin: *
p3p: CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"
I just tried this things :
1: setting default Content-Type even text/plain and other types [Not Working]
$httpProvider.defaults.headers.common['Content-Type'] ='application/x-www-form-urlencoded; charset=UTF-8';
Because I'm using Atom Electron shell for running my app , the quick solution for me was using --disable-web-security
for disabling CORS protection in browser .