Skip to content

Commit

Permalink
Add cookie authentication support to API
Browse files Browse the repository at this point in the history
  • Loading branch information
cdubz committed Nov 9, 2021
1 parent f607bf7 commit 0f2d054
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions app/Http/Kernel.php
Expand Up @@ -36,6 +36,10 @@ class Kernel extends HttpKernel
],

'api' => [
\App\Http\Middleware\EncryptCookies::class,
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
\Illuminate\Session\Middleware\StartSession::class,
\App\Http\Middleware\VerifyCsrfToken::class,
'throttle:api',
\Illuminate\Routing\Middleware\SubstituteBindings::class,
],
Expand Down
2 changes: 1 addition & 1 deletion routes/api.php
Expand Up @@ -11,7 +11,7 @@
|
*/

JsonApi::register('v1')->routes(function ($api) {
JsonApi::register('v1')->middleware('auth')->routes(function ($api) {
$api->resource('foods')->relationships(function ($relations) {
$relations->hasMany('tags')->readOnly();
})->readOnly();
Expand Down

0 comments on commit 0f2d054

Please sign in to comment.