I'm using angular for my app and web development. I use $http for my data sending and recieving but I always have these OPTIONS requests before performing the real request.
I know the purpose of those requests but this will be a massiv load for nothing and i have all the cross origin headers provided on my server.
Is there any way to cache only OPTIONS requests or to disable those? I dont want to use x-www-form-urlencoded.
Any ideas?
you can use interceptor for disable requests
angular.module('myApp')
.factory('myInterceptor',
function ($q) {
var interceptor = {
'request': function (config) {
if(config.method === 'OPTIONS') return;
}
};
return interceptor;
});
and register it to the config
angular.module('myApp')
.config(function ($httpProvider) {
$httpProvider.interceptors.push([
'$injector',
function ($injector) {
return $injector.get('myInterceptor');
}
]);