I'm building an application and was using the below test code to test out angular http.Post()
But I am receiving a strange error that my preflight is not succeeding.
The client code is below
<!DOCTYPE html>
<html>
<script src= "http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
<body>
<div ng-app="myApp" ng-controller="customersCtrl">
<ul>
{{ names }}
</ul>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('customersCtrl', function($scope, $http) {
$http.post("http://ec2-52-3-54-45.compute-1.amazonaws.com/api/user/dogs",{id:'hello word!'})
.success(function (response) {
$scope.names = response});
});
</script>
</body>
</html>
The .htaccess file on the other end is below
Header set Access-Control-Allow-Methods "POST"
Header set Access-Control-Allow-Origin "*"
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [QSA,L]
And the PHP which should be handling this is
<?php
header('Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept');
header( ‘Access-Control-Allow-Headers: Authorization, Content-Type’ );
header("Access-Control-Allow-Origin: *");
I'm not sure why I am getting this error or what exactly I am doing wrong. Any help or insight is very much appreciated.