I have this part of code
App.factory('httpRequestInterceptor', function () { return { request: function (config) { console.log(config) config.headers['Access-Control-Allow-Origin'] = '*'; config.headers['Access-Control-Allow-Methods'] = 'GET, PUT, POST, DELETE, HEAD, OPTIONS'; config.headers['Access-Control-Allow-Credentials'] = 'true'; config.headers['Access-Control-Allow-Headers'] = 'X-Requested-With, origin, content-type, accept, application/xml;charset=utf-8'; return config; } }; });
and this
App.config(['$stateProvider', '$httpProvider', '$locationProvider', '$urlRouterProvider', '$ocLazyLoadProvider', function ($stateProvider, $httpProvider, $locationProvider, $urlRouterProvider, $ocLazyLoadProvider) { $httpProvider.interceptors.push('httpRequestInterceptor');}]); Now everytime that run i get this error Request header field Access-Control-Allow-Origin is not allowed by Access-Control-Allow-Headers in preflight response.