Ajax REST: PUT / DELETE does not work

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 static Client: Front that makes AJAX GET / POST / PUT / DELETE for the API above.

GET / POST happens normal, but when I do a PUT / DELETE it returns:

  

"Access-Control-Allow-Origin" header is present on the requested resource "

What does not make sense, because if it did not have Origin, neither POST would work.

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);
            });
        }
    ...

}

Is there any light?

    
asked by anonymous 12.01.2016 / 22:04

1 answer

1

I was able to solve my problem, it was Laravel's CSRF that was blocking me. I solved it by implementing a token:)

    
14.01.2016 / 14:34