How to use vue router instead of laravel routing just for certain urls
I don't know if this is possible as my knowledge of Vue isn't that strong just yet. Is there a way to have the front (customer-facing) part of a website coded in Laravel with Laravel routing but have the back coded in Vue with Vue routing? I have Vue there now with Vue router, but when you click one of the links it updates the URL as expected and goes to the right page, but when you hit refresh, Laravel (I think) tries to look for the URL but then 404s.
How do I tell that specific part of the site to let Vue router deal with the routing and not Laravel?
I am doing the somewhat same with react and it works great. This is my route specification. All calls to /admin are passed to a single method that just passes the data to react.
Hmm that doesn't seem to be working quite right for me. I can get to the admin dashboard main page which is dashboard.test/admin just fine but when I click one of the links in there it changes the URL to dashboard.test/users (for example) and when you hit refresh it 404s again
Try pointing at the link and see what it says in the lower left corner. is it the proper url?
Also remember to not just copy my middleware. I dont assume you have an 'ip' middleware :)
you are looking for Vue SPA system?
and you describe wrong : laravel handles the backend , vue is a frontend framework
check vue-router
and , in your laravel web routes
Route::any('/{any}', function () {
return view('welcome');
})->where(['any' => '.*']);
I don't think I did describe it wrong. What I mean is I want Laravel routing to handle just the front end customer-facing pages and I wanted Vue router to just handle the back admin page that the users see. That solution you posted just seems to make Vue router handle all the routing by the looks
@sinnbeck
if you are using Vue SPA, there is no need to return another laravel view .
Vue-router could handle mutilple vue view pages.
laravel can provide data as json format , so vue can CRUD them through axios.
in his case , if he is using history mode , laravel could conflict to vue routers.
@maverickchan Yes exactly. My AdminController::index just returns view('admin') :) I just dont use closures in web.php as that cannot be cached by laravel.
I found the issue. In my URLs I was appending /pagehere at the end of dashboard.test/. Fixed by appending /admin/pagehere instead. Is this the 'correct' solution or is there supposed to be a more elegant way?
I personally create my routes in react this way (execpt I dont use the domain). I have a function that creates them, that return something like this (a bit more elegant but I hope you get the idea)