#creating api routes
5 messages · Page 1 of 1 (latest)
Not really, but why would you not want to separate API routes from standard web routes, If you read the comment in each you'll see what the difference is
there is a middleware group on any of them (web.php or api.php)
for example in web.php routes you want to use VerifyCsrfToken middleware for verifying csrf token.
and also you use sessions in web.php routes but you don't use them in api.php routes since it's stateless.
you can see that in https://github.com/laravel/laravel/blob/10.x/app/Http/Kernel.php
and https://github.com/laravel/laravel/blob/10.x/app/Providers/RouteServiceProvider.php
Why would you not place API routes in your routes/api.php file…? Like, the file name is quite a big giveaway as to what it’s for.
yep already did that, never worked with api routes before, but managed to make it work fine! 🙂