I use this starter Laravel + Vue SPA where I have such a router in web.php:
Route::get('/{any}', 'SpaController@index')->where('any', '.*');
But when I make a request for an api with a nonexistent url, I would like to return a response via
Route::fallback(function() {
return response()->json(['message' => 'Not Found!'], 404);
});
This route does not work and instead of it the request goes to this route:
Route::get('/{any}', 'SpaController@index')->where('any', '.*');
I understand I need to change ->where('any', '.*'); but not sure how.
SpaController@indexto make laravel+vue SPA - Afraz AhmadRoute::fallbackwork? I need to show 404 for api - Илья Зеленько