Refresh page conflicting between laravel and vuejs

0

I'm studying the integration between laravel and vuejs, however, when I configure the routes on the vue-router, when I refresh the page, laravel does not find the page or else I need to go back to the index of the application to run it again . I'm not sure if this is a good way to do this, but I'm not going to be able to do that. sends only raw json, instead of returning the json to the vuejs and from there popular the page. I need to return to the index of the application, click again on the link of the page I want to go and then get the data through the vue. If I refresh the page everything happens again, in summary, every time the page is updated with f5, laravel does not identify the routing of the vues. If the page does not return data, the laravel displays the typical page not found, if there is data return, raw data is shown, straight on the page, without going through the vues. Does anyone know how to solve it?

    
asked by anonymous 10.01.2018 / 05:17

1 answer

0

Felipe, I went through this same problem now and I treated it like this:

I left the web route (routes / web.php) as follows:

Route::any('{all}', function () {
    return view('index');
})->where(['all' => '.*']);
So all the routes will play for my view that calls the vue, and the calls to the api were all for the route of api (routes / api.php), in vue the calls to laravel will all be in / api

I'm starting with VueJs this week so it might be wrong to work that way, but for me it seemed to make sense that way, so I'm already leaving the API ready to be consumed by the front, and any web call Laravel simply goes through responsibility to interpret the route to the Vue.

If I am wrong in this thought, please someone correct me.

    
11.01.2018 / 14:33