Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

p0t4t0's avatar

Getting the Laravel 404 page with React Router 4

I am using the React preset that comes along with Laravel: php artisan preset react and I seem to be having problems with it concerning routing with React. Every time I specify a /somewhere everything works fine but when I specify one route deeper /somewhere/one-level-deep it gives the 404 page. Anyone have any idea what is wrong? I tried with create-react-app and it works fine.

0 likes
2 replies
tykus's avatar
tykus
Best Answer
Level 104

How have you defined the Laravel catch all route?

The following should do it for you:

Route::get({any}, function () {
    return view('index'); // or wherever your React app is bootstrapped.
})->where('any', '.*');
2 likes

Please or to participate in this conversation.