0

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 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.