Access to XMLHttpRequest at 'http://localhost:8000/api/mydata'
from origin 'http://localhost:8080' has been blocked by
CORS policy: No 'Access-Control-Allow-Origin'
header is present on the requested resource.
Solution:
- Install
$ composer require barryvdh/laravel-cors
open file Kernel.php and put \Barryvdh\Cors\HandleCors::class, on protected middleware
protected $middleware = [
\App\Http\Middleware\CheckForMaintenanceMode::class,
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
\App\Http\Middleware\TrimStrings::class,
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
\App\Http\Middleware\TrustProxies::class,
\Barryvdh\Cors\HandleCors::class,
];