Laravel: Catch all routes that does not have /api/ segment

后端 未结 2 1868
遇见更好的自我
遇见更好的自我 2021-02-19 21:35

I need to catch all routes, except those that have /api/ segment in them. I know how to catch every single route

Route::any(\'{all}\', \'AngularController@serveF         


        
2条回答
  •  臣服心动
    2021-02-19 22:19

    You can catch all routes where the path does not start with api

    Route::any('{all}', 'AngularController@serveFrontend')->where('all', '^(?!api).*$');
    

    Or simply leave your catchall as the last route and it'll work as expected.

提交回复
热议问题