I am using slim php framework using nginx , i have enabled CORS also . Now when i make a request to my Rest API from some other domain, the option method is invoked first , then post method is invoked with actual post data. Response for POST is 200 but there is no data coming from API .
But when i try the same with same domain , everything works perfect.
WORKING
$.ajax({
url: "http://172.19.4.130/oam_restapi/restapi/loginpost",
type: 'post',
dataType: 'json',
contentType: "application/json; charset=utf-8",
crossDomain:true,
data : JSON.stringify({
"username" : "admin",
"password" : "admin!23B",
"domain" : "local"
}),
success: function(res) {
console.log(res);
}
});
when this ajax call is made like 172.19.4.130/makeajax.html
Not working
When this same call is made like localhost/makeajax.html
I understand CORS , and the same was working with APACHE earlier
Nginx Configuration
location /oam_restapi/restapi/ {
satisfy any;
add_header Access-Control-Allow-Origin *;
root /html/oam_restapi/restapi/;
index index.php;
try_files $uri /oam_restapi/restapi/index.php;
}