0
I have 2 applications:
1) a Rest API on an XPTO server (Using Laravel 5.1), which has:
->header('Access-Control-Allow-Origin', '*.xpto.com.br')
->header('Access-Control-Allow-Credentials', 'true')
->header('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE')
->header('Access-Control-Allow-Headers', 'Origin, Content-Type, Content-Range, Content-Disposition, Content-Description');
2) In my Client: Static Front that makes AJAX GET/POST/PUT/DELETE for API above.
GET/POST happens normal, but when I do a PUT/DELETE it returns:
"Response to preflight request doesn’t pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested Resource"
Which doesn’t make much sense, because if I didn’t have Origin, neither would the POST.
Method I use:
var objXPTO = function() {
...
this.Ajax = function(url,type,args,callback) {
//console.log(url,type,args,callback);
$.ajax({
url: url,
method: type,
data: args
}).done(function(data) {
callback(data);
});
}
...
}
Below has some light?
puts
_method: 'PUT'
as argument and test the call.– Marco Aurélio Deleu
@bgsouza, worked with the help of the above comment?
– Ruggi
Hello @Ruggi and Marco I tested like this and did not roll My code was right, I saw today that the problem was the CSRF of Laravel 5.1 Thanks for the help
– bgsouza
So @bgsouza answer your own question and answer it, so someone who has the same problem you know how to handle the situation.
– Ruggi
@Ruggi decsulpe but the usability of this here is horrible
– bgsouza