The following is a basic guide to setup authentication for Luma Vue using an external Laravel 8.x API.
Requirements
- Composer: Luma Vue authentication example utilizes Composer to manage its server-side dependencies. So, before using Luma Vue authentication example, make sure you have Composer installed on your machine.
- Server Requirements: Luma Vue authentication example has a few system requirements. See https://laravel.com/docs/8.x#server-requirements
Setup Laravel
Create a new Laravel project.
Database
Enable sqlite database connection in the .env
file:
Create the database file:
Laravel Fortify
Install Laravel Fortify:
Publish the Fortify configuration:
Register the Fortify Service Provider in config/app.php
:
Laravel Sanctum
Install Laravel Sanctum:
Publish the Sanctum configuration:
Next, add Sanctum's middleware to your api
middleware group within your app/Http/Kernel.php
file:
Configure Your First-Party Domains in .env
. This should match the hostname and PORT of the SPA:
CORS
Configure CORS in config/cors.php
:
CSRF
Disable CSRF Token in app/Http/Middleware/VerifyCsrfToken.php
:
Routes
Create a mock /home
route in routes/web.php
so we don't get a 404 after login:
Update the /api/user
route in routes/api.php
to use sanctum
:
Frontend Matter
Beautifully crafted Bootstrap themes and templates for modern web apps.
Copyright 2020 © All rights reserved.
Illustrations by Freepik Storyset