Instead of putting a dozen headers in hoping to hit ones that are included,
have you tried just returning the ones that it sends in 
Access-Control-Request-Headers ?
That is the technique for replying to the Origin request... echo back what 
it wants.

I'm seeing a small percentage of IOS browsers on 8.1 on phone or ipad fail 
CORS POST requests after the OPTION request,
but it is only a small percentage, and I can't reproduce.

On Wednesday, February 4, 2015 at 8:42:39 PM UTC+11, Jörg Zimmer wrote:
>
> Hey Rob,
>
> I think you will bang your head now, as I just did...
> I also have it working just in this second... BUT: I just did some apache 
> config:
>
> Header always set Access-Control-Allow-Headers 
> "Origin,X-Requested-With,Content-Type,Accept,Authorization,Accept-Language,Content-Language,Last-Event-ID,X-HTTP-Method-Override"
> Header always set Access-Control-Allow-Methods 
> "GET,POST,PUT,DELETE,OPTIONS"
> Header always set Access-Control-Allow-Credentials "true"
> Header always set Cache-Control "max-age=0"
>
> I added the Headers for credentials and cache-control plus the 
> allow-headers entry for X-HTTP-Method-Override.
> Don't know what exactly does the trick, but even the older Version of my 
> angular-app now works on my iPhone with iOS8...
>
> Will do some more testing, but I think this was it....
>
>
>
>
>
> Am Mittwoch, 4. Februar 2015 01:56:44 UTC+1 schrieb Rob Koberg:
>>
>> I have this working now, but I had to use jQuery.ajax and not angular's 
>> own. Here is what works:
>>
>>
>> SessionCreator.$inject = ['$http', '$q', '$rootScope', '$timeout', 'ENV', 
>> 'User'];
>> function SessionCreator($http, $q, $rootScope, $timeout, ENV, User) {
>>
>>   var deferred = $q.defer();
>>
>>   jQuery.ajax(ENV.apiEndPoint + '/user-init', {
>>
>>     accepts: 'application/json',
>>     dataType: 'json',
>>     headers: {
>>       Accept: 'application/json',
>>       Authorization: User.getAuth()
>>     },
>>
>>
>>     success: function(data) {
>>
>>       $rootScope.maintenance = false;
>>       User.init(data.user);
>>       $rootScope.totalReads = data.totalReads;
>>
>>       if (data.maintenance) {
>>         $rootScope.maintenance = true;
>>         $rootScope.maintenanceMsg = data.content;
>>       }
>>
>>       deferred.resolve();
>>     },
>>     error: function(jqXHR, status, errorThrown) {
>>       console.log('SessionCreator error jqXHR', jqXHR);
>>       console.log('SessionCreator error status', status);
>>       console.log('SessionCreator error errorThrown', errorThrown);
>>
>>         User.init(data.user);
>>         $rootScope.totalReads = data.totalReads;
>>         if (data.maintenance) {
>>           $rootScope.maintenance = true;
>>           $rootScope.maintenanceMsg = data.content;
>>         }
>>       jQuery('.loader-wrap').fadeOut();
>>       $timeout(function() {});
>>
>>     }
>>   });
>>
>>   return deferred.promise;
>> }
>>
>>
>> This does not work:
>>
>>
>> SessionCreator.$inject = ['$http', '$q', '$rootScope', '$timeout', 'ENV', 
>> 'User'];
>> function SessionCreator($http, $q, $rootScope, $timeout, ENV, User) {
>>
>>   var deferred = $q.defer();
>>
>> // used text here to try and avoid preflight request. Didn't work.
>>   $http
>>     .get(ENV.apiEndPoint + '/user-init',
>>       {
>>         responseType: 'text',
>>         headers: {
>>           Accept: 'text/plain'
>>         }
>>       }
>>     )
>>     .success(function(data) {
>>       $rootScope.maintenance = false;
>>       User.init(data.user);
>>       $rootScope.totalReads = data.totalReads;
>>   
>>       if (data.maintenance) {
>>         $rootScope.maintenance = true;
>>         $rootScope.maintenanceMsg = data.content;
>>       }
>>   
>>       deferred.resolve();
>>     })
>>     .error(function(data, status, headers, config) {
>>       console.log('SessionCreator error data', data);
>>       console.log('SessionCreator error status', status);
>>       console.log('SessionCreator error headers', headers);
>>       console.log('SessionCreator error config', config);
>>   
>>         User.init(data.user);
>>         $rootScope.totalReads = data.totalReads;
>>         if (data.maintenance) {
>>           $rootScope.maintenance = true;
>>           $rootScope.maintenanceMsg = data.content;
>>         }
>>       jQuery('.loader-wrap').fadeOut();
>>       $timeout(function() {});
>>   
>>     });
>>
>>   return deferred.promise;
>> }
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to