0
votes

I'm already doing a project in laravel and I'm added vue router to it. after add "mode:'history" it remove the "#" but after if I refresh the page it says 404 error. so I add this line to web.php

Route::get('/{any}', 'HomeController@index')->where('any', '.*');

after that it fixed the refresh issue but now my Axios request not working.. all Axios request reposed gave the home page.. how can fix it?

1

1 Answers

1
votes

That any route should be the last route entry in your router file. Laravel routing honors top down registration of Routes, it will use the first match it finds.

If that any wildcard entry is at the top of the Laravel router file then anything written after (below it) will be ignored.


Route::get('/example-1', 'HomeController@exampleOne'); // Will work

// If nothing else above this line matches then run Vue App
Route::get('/{any}', 'HomeController@index')->where('any', '.*');

// Anything written here will be ignored.
Route::get('/example-2', 'HomeController@exampleTwo') // Not work