Join the Stack Overflow Community
Stack Overflow is a community of 6.4 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

I am trying to add some custom headers to an API request.

var headers = {
                'ivClient': 'CUSC',
                'ivDARoles': 'NEWC,CUSC,BEND',
                'ivGroups': 'AccountView,AccountWrite',
                'ivUser': 'Anwar'
              }

And passing this headers variable into the $http service like this :

$http({url:url, method:method, headers:headers, params:params, data:data })

When i am trying to execute the same API request from the REST POSTMAN, getting this in header section of network tab :

enter image description here

Here, key-value pair is coming properly and also getting the correct response from the api.

But when executing the same API request from the code getting this in header section of network tab :

enter image description here

Here, all keys are comes under same header Access-control-Request-Headers without any value and also getting "No 'Access-Control-Allow-Origin'" error in console.

share|improve this question
    
This looks like a pre-flight OPTIONS request for CORS. You're sending a cross-domain request, and your server needs to be configured to accept those request and headers. Google for CORS. – JB Nizet 20 hours ago
    
The problem is not with the custom headers, your api is not configured to accept cross domain request. Make sure you have Access-Control-Allow-Origin header set to "*" or the specific ip address you want this access from. – suzo 20 hours ago
    

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.