Laravel Vue-cli scaffolded project with Vuetify UI library. NOTE:This application scaffold inspired by darryldecode's laravel-starter-kit
git clone https://github.com/ashkan90/Laravel-Vue-Scaffold.git
cd Laravel-Vue-Scaffold
composer install
cd frontend
npm install
Most common supply from developers for using Vue with Laravel's API In this scaffold is needed to use CORS to deal with API. So you can change your local settings for CORS.
Located at: App\Http\Middleware\Cors
public function handle($request, Closure $next)
{
if($request->server('HTTP_ORIGIN')) {
$origin = $request->server('HTTP_ORIGIN');
$domain = Domain::where("domain", $origin)->get();
if($domain) {
header('Access-Control-Allow-Origin: ' . $origin);
header('Access-Control-Allow-Headers: Origin, Content-Type');
}
}
return $next($request);
}
As you can see, we need to make sure that we've inserted our local urls to 'Domain' Model.
public function up()
{
Schema::create('domains', function (Blueprint $table) {
$table->increments('id');
$table->string('domain', 150)->unique();
$table->timestamps();
});
}
Absolutely we've to seed our local urls before we started to develop something great!
$domains = ["http://127.0.0.1:8000", "http://192.168.1.30:8080"];
foreach ($domains as $domain) {
App\Domain::create(["domain" => $domain]);
}
php artisan migrate
php artisan db:seed
php artisan serve
cd frontend
npm run serve