Skip to content

Instantly share code, notes, and snippets.

@0test
Created March 27, 2023 11:58
Show Gist options
  • Save 0test/248e9fe1b9ea0d583d1dc48e36e3bdc7 to your computer and use it in GitHub Desktop.
Save 0test/248e9fe1b9ea0d583d1dc48e36e3bdc7 to your computer and use it in GitHub Desktop.
sanctum.md

sanctum

Как делал

  • composer create-project laravel/laravel
  • composer require laravel/sanctum
  • php artisan migrate
  • app/Http/Kernel.php
'api' => [
    \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
    'throttle:api',
    \Illuminate\Routing\Middleware\SubstituteBindings::class,
],
  • App\Models\User добавил трейт HasApiTokens

  • докинул миграцию на nullable name

  • написал UserSeeder, вызов php artisan db:seed --class=UserSeeder

  • composer require laravel/ui

  • php artisan ui:auth

  • В .env SANCTUM_STATEFUL_DOMAINS="sanctum.laravel"

  • php artisan ui bootstrap

  • php artisan ui vue

  • npm install

  • npm install vue router//npm install --save vue-router

  • создал свой /layouts/app.blade.php с vite @vite(['resources/js/app.js', 'resources/sass/app.scss'])

  • js/router.js

  • В config\cors.php ставим 'supports_credentials' => true,

  • resources\js\bootstrap.js window.axios.defaults.withCredentials = true;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment