0

I have a Lumen application which frontends uses ReactJS and on backend Lumen acts as a rest-api. With ReactJS I use react-router and when I refresh a react route than Lumen tries to find it's own.

$app->get('client', 'ApiController@index'); 

is the entry point to my ReactApp and I wonder if I could allocate all routes like client/* for React.

Is there a a way to do this?

fefe
  • 8,755
  • 27
  • 104
  • 180

1 Answers1

0

Yes, you'll just have to define one more route:

$app->get('client/{namedParamEventhoughYouDoNotUseIt:.+}', 'ApiController@index'); 
Rick Jolly
  • 2,949
  • 2
  • 23
  • 31
  • 1
    Can you please extend your answer to return a view. For example, `$router->get('/client/.*', function () use ($router) { return view('index'); });` – Avinash L Jul 23 '20 at 10:51