I\'m working on Laravel 5.4 and my routes are in the api middleware
I see that I need to transfer my routes to the web middleware, but I need them to be on the api m
CSRF protection prevents attacks using a previously authenticated user (normally setting a state using session) https://www.owasp.org/index.php/Cross-Site_Request_Forgery_(CSRF).
A restful API do not have state https://en.wikipedia.org/wiki/Representational_state_transfer, so there is no session to attack. So in a restful API the CSRF protection is to authenticate the user on each request, if you are only authenticating the user on the first request and use session for the following requests you are not making a restfull API and should use the web middleware.
Edit: How are you going to get the CSRF token to the client if you don't have any state?