So, I'm trying to intercept the http calls to add the Authorization header on each call if exist. This works well exept of the fact that no matter which http method I use (GET, POST, DELETE) it send the request with OPTIONS method instead. What am I doing wrong?
Server is nodejs with restify.
angular.module('mymodule').factory('RequestService', function () {
var token = null;
var service = {
setToken: function setToken(_token) {
token = _token;
},
getToken: function getToken() {
return token;
},
request: function request(config) {
if (token) {
config.headers['Authorization'] = 'Token' + token;
}
return config;
}
}
return service;
}).config(function($httpProvider) {
$httpProvider.interceptors.push('RequestService');
}