I am in Laravel 5.8 - I kept getting this CORS issue

I\'ve tried
php artisan make:mi
Try to set the CORS middleware as a global middleware.
the handle function in the CORS middleware:
public function handle($request, Closure $next)
{
return $next($request)
->header('Access-Control-Allow-Origin', '*')
->header('Access-Control-Allow-Methods', 'GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS')
->header('Access-Control-Allow-Headers', 'Content-Type, Authorization');
}
to add this middleware globally, go to App\Http\Kernel, and add this line in the $middleware array:
\App\Http\Middleware\Cors::class,
you can also add this code in the bootstrap/app.php
header('Access-Control-Allow-Origin', '*');
header('Access-Control-Allow-Methods', 'GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS');
header('Access-Control-Allow-Headers', 'Content-Type, Authorization');
hope it works!