Answer the question
In order to leave comments, you need to log in
api.php and web.php in laravel?
Hello. Tell me in which cases it is worth defining routes in api.php, and in which in web.php. It is clear that the difference is only in the addition of the 'api' prefix, but what is the conceptual difference? Should I make all ajax requests and all interactions with data by working with api? But only in the case when I just need to give the view to use web.php?
Answer the question
In order to leave comments, you need to log in
It is clear that the difference is only in the addition of the 'api' prefix, but what is the conceptual difference?The difference is not just the addition of the prefix. Different middleware groups apply to these routes (they are described in your RouteServiceProvider). This, in general, is the answer to your question - choose based on the required middleware.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question