Reputation: 120
I'm building SPA (Single-page-application) by Laravel and React JS.
I have some API routes in api.php
of Laravel.
And I defined this route in web.php
of Laravel to handle web routes by React JS.
Route::view('{any}', 'app')->where('any', '.*');
But the problem is that API routes are handled by the above code.
What should I to do ?
I don't want to write routes in Laravel and rewrite them in React JS twice.
Upvotes: 0
Views: 988
Reputation: 510
Use these routes
Route::view('/{any?}', 'app')->where('any', '^(?!api\/)[\/\w\.-]*');
This will exclude api routes
Upvotes: 2