Laravel directing HTTP method to erroneous function on Controller

0

I have a project in Laravel and Vue.js where I have a function in Vue.js that sends a post with the data of a form, so far so good, except that when the this.$http.post() function makes the request for the backend, the laravel directs to the wrong method, it should send to the method store (that deals with the post requests), however it sends to the method index (responsible for GET requests), a detail is that I am using RestFull Controllers , then all methods are being accessed based on the request being made (or at least should be).

One detail is that locally on the machine I use to develop works perfectly, and on another local server machine, it also works perfectly, now putting that project on the Amazon production server happens as I mentioned above.

The settings are as follows:

  

Local machine

     

PHP 5.6.28

  

Local Server

     

PHP 7.0

  

Amazon Server (EC2)

     

PHP 5.6.30

What can be happening? I've really thought of a lot of possibilities and I have no idea what that can be.

    
asked by anonymous 13.07.2017 / 23:41

2 answers

0

I found the solution, actually found the answer in the foreign forum, what was happening was that the url in the $ http methods were with a "/" (slash) at the end, for example: "test.com/api/v1/resource/"

I just took it like this: "test.com/api/v1/resource"

Doing this worked.

    
14.07.2017 / 20:52
0

It happens that when working with VueResource, in some projects you have to tell it to emulate a normal HTTP request.

To perform this configuration, add the Configs parameter to VueResource, it would look like this:

var config = {
    emulateJSON: true,
    emulateHTTP: true
};

// Adicionado o CONFIG para emular
this.$http.post(url, data, config).then((val) => {
    console.log(val);
});
    
14.07.2017 / 18:38