If you installed Laravel after 5.2.26, you will have the 'web' group applied to all your routes in routes.php
. To add API routes that don't need the 'web' middleware group you can create another routes file to hold those routes and load them in your RouteServiceProvider
separately.
- Create a
api-routes.php
file in the same directory as yourroutes.php
file. - Put your API routes in the
api-routes.php
file. - Adjust your
RouteServiceProvider
(app/Providers/RouterServiceProvider.php
) to add what is in the exampleRouteServiceProvider
provided.- Adjust
namespace
andmiddleware
values of the array passed togroup
inmapApiRoutes
to what you would like.
- Adjust