0

I have interceptor service to add a header to all my requests. However occasionally I don't need this header, so following Angular's documentation I set it to undefined:

$http({
    url: 'https://hooks.slack.com/services/',
    method: 'POST',
    data: {test: 'test message'},
    headers: {
        'my-header': undefined
    }
})

But I still get Request header field my-header is not allowed by Access-Control-Allow-Headers in preflight response

What am I doing wrong?

UPDATE: I tried setting headers to {}, I tried setting Content-type to text/plain and application/x-www-form-urlencoded which shouldn't be triggering the preflight. But apparently because of custom headers which is what my-header is the pre-flight is still issued.

chibis
  • 658
  • 2
  • 12
  • 22
  • leave headers empty, don't put my-header in it – yBrodsky Nov 15 '17 at 20:35
  • Possible duplicate of [Set defaults header on AngularJS but don't use it on one specific request](https://stackoverflow.com/questions/23696202/set-defaults-header-on-angularjs-but-dont-use-it-on-one-specific-request) – Tristan Hessell Nov 16 '17 at 02:45

0 Answers0