$http request OPTIONS? how to fix it?

Hello so i’m trying to call my backend and getting some strange issue with calling post method.

Remote Address:192.168.58.183:80
Request URL:http://192.168.58.183/ESService/ESService.svc/CreateNewAccount
Request Method:OPTIONS
Status Code:405 Method Not Allowed
Request Headersview source
Accept:*/*
Accept-Encoding:gzip, deflate, sdch
Accept-Language:en-US,en;q=0.8,pl;q=0.6
Access-Control-Request-Headers:accept, content-type
Access-Control-Request-Method:POST
Connection:keep-alive
Host:192.168.58.183
Origin:http://localhost:8100
Referer:http://localhost:8100/
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.93 Safari/537.36
Response Headersview source
Access-Control-Allow-Headers:Content-Type, Accept
Access-Control-Allow-Methods:POST,GET,OPTIONS
Access-Control-Allow-Origin:*
Access-Control-Max-Age:1728000
Allow:POST    
Content-Length:1565
Content-Type:text/html; charset=UTF-8
Date:Mon, 02 Feb 2015 09:11:17 GMT
Server:Microsoft-IIS/7.5
X-Powered-By:ASP.NET

And my code looks like here i think this call is okay can someone review it?

$scope.RegisterUser = function(){
var us = {
  UserName:$scope.userName,
  Password:$scope.password,
  UserRoleID:null,
  Company:$scope.company,
  Terms:$scope.terms,
  ID:null,
  BuyerID:app.buyerId
};

$http({method:'POST', url:app.wcf + '/CreateNewAccount', data:{us:us}})
.then(
    function(resp){
     app.Logger(resp.data);
    },
    function(err){
      app.Logger(err);
})};

Then you have a CORS problem :wink:

start your chrome with --disable-web-security
or allow Cross Origin in your webserver.

Take a look here:

1 Like

Just add

headers: {‘Content-Type’: ‘application/x-www-form-urlencoded’}

to your $http method. See stackoverflow for more details.

Ye stack helped me needed to add CORS support into backend.

Here is my post