-1

I am using an API call in cross domain where In chrome I am getting this response . I have all the headers included in my REST API in other domain .

  <add name="Access-Control-Allow-Origin" value="*"/>
        <add name="X-Content-Type-Options" value="nosniff"/>
        <add name="X-XSS-Protection" value="1;"/>
        <remove name="X-Powered-By"/>
        <add name="Access-Control-Allow-Headers" value="Origin, X-Requested-With, Content-Type, Accept"/>
        <add name="Access-Control-Allow-Methods" value="POST,GET"/>

And this is my API Call from angular .

$scope.XYZ=customURLWithoutArray.save({
         controller:"XYZController",
            actionName:"ABCACTIONNAME",
             UserId: "VC"
         },
            function($success){

       return $success;
              },function($error){
      return $error;
    });    

It is able to hit the controller but data is null.

1 Answers1

0

As you might already know, a preflight request sends a HTTP OPTIONS request.

In your configuration (I assume its some IIS server?) you have this:

 <add name="Access-Control-Allow-Methods" value="POST,GET"/>

Which means you're not allowing OPTIONS.

So try modifying it to this:

 <add name="Access-Control-Allow-Methods" value="POST,GET,OPTIONS/>

More information on configuring IIS for CORS:
https://stackoverflow.com/a/31084417/6139050

Community
  • 1
  • 1
kazenorin
  • 1,455
  • 8
  • 16