Costum HTTP Request Headers not working

I am having some problems sending costum request headers to the server

I wrote the following


.factory(‘httpRequestInterceptor’, [’$rootScope’, function ($rootScope) {
return {
request: function ($config) {
$config.headers[‘x-auth-ticket’] = “test”;
return $config;

However when I do a request i get

Request header field x-auth-ticket is not allowed by Access-Control-Allow-Headers in preflight response.

and the Header istead of being there is added in

Access-Control-Request-Headers:accept, x-auth-ticket

so my header

x-auth-ticket: test

is not in the Request headers. Do i have to configure something else in ionic? Or could it be something on the server side?

This is normal behavior from client, before sending your header, client asks the server permission to use x-auth-ticket header and this is why it looks like the interceptor was putting header in wrong place.

Your server must allow it,
So either you set your server to accept all headers:

 Access-Control-Allow-Headers: *

Or you restrict to the ones you want including x-auth-ticket header:

 Access-Control-Allow-Headers: origin, content-type, accept, x-auth-ticket