laravel configuration route Detailed explanation of the difference between routes defined by api and web

  • 2021-12-19 06:07:57
  • OfStack

1. Routing through middleware is different

Open kerenl. php to see the difference


 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',
  ],
 ];

2. The path is not 1

The route written in web. php looks like this

eg:http://quan.cms/backend/admin/add

The route written in api. php needs to be added with XXX/api/route address, which is equivalent to adding api layer 1 on the basis of web. php

eg:http://quan.cms/api/backend/admin/add


Related articles: