Использовать $ http Interceptor
С помощью перехватчика $ http вы можете отправлять заголовки в конец или наоборот, а также выполнять свои проверки.
Отличная статья о перехватчиках $ http
Пример:
$httpProvider.interceptors.push(function ($q) {
return {
'response': function (response) {
// TODO Create check for user authentication. With every request send "headers" or do some other check
return response;
},
'responseError': function (reject) {
// Forbidden
if(reject.status == 403) {
console.log('This page is forbidden.');
window.location = '/';
// Unauthorized
} else if(reject.status == 401) {
console.log("You're not authorized to view this page.");
window.location = '/';
}
return $q.reject(reject);
}
};
});
Поместите это в свою .config или .run функцию.