C
C
chelkaz2017-06-05 16:27:14
Laravel
chelkaz, 2017-06-05 16:27:14

Laravel Where to use the Route API?

Tell me how is it right?
I have a big database.
I'm doing a project on Laravel, and there are different requests from users.
For example: Search request (for everyone), vote request (for registered users), view request (data by id), and so on.
Now it's all through the WEB router. But I would like to make a client on VUE.js in the future, and Laravel under the API.
And if it will be one whole application, then I do not need the Authentication (Passport) API ?
As I understand it, since I have everything in one application, then I just need to make all requests through the API router and not the WEB will do it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vasily Nazarov, 2017-06-05
@vnaz

you just need all requests through the router API

Not all, but only AJAX requests.
In the future, make an API, because API and "regular" pages are a very, very different approach to web development. They, of course, can coexist in one project, but these are, as it were, two different sides.

B
Barmunk, 2017-06-06
@Barmunk

difference between api routes and web

protected $middlewareGroups = [
        'web' => [
            \App\Http\Middleware\EncryptCookies::class,
            \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
            \Illuminate\Session\Middleware\StartSession::class,
            // \Illuminate\Session\Middleware\AuthenticateSession::class,
            \Illuminate\View\Middleware\ShareErrorsFromSession::class,
            \App\Http\Middleware\VerifyCsrfToken::class,
            \Illuminate\Routing\Middleware\SubstituteBindings::class,
        ],
        'api' => [
            'throttle:60,1',
            'bindings',
        ],
    ];

https://github.com/laravel/laravel/blob/master/app...
Basically, the most critical difference is the VerifyCsrfToken protection, which is not in the api by design.
https://learn.javascript.ru/csrf
https://laravel.com/docs/5.4/csrf

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question