How to Avoid 404 Error when Reload a Page in React and Laravel
When working in SPA using React js and Laravel and you try to reload the page you get a 404 error not found page, so how we can fix this problem?
Update the route
All we need to do is to update our route like the code below:
<?php
use Illuminate\Support\Facades\Route;
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Route::get('{any}', function () {
return view('home');
})->where('any','.*');