I added this package in my laravel api:
I added the middleware in my global middleware:
protected $middleware = [
\Spatie\Cors\Cors::class,
...
];
I do this in my config/cors.php
file:
'allow_origins' => [
'http://localhost',
],
Even though I still get this error:
Access to XMLHttpRequest at 'http://api.local/api/request' from origin 'http://localhost:8080' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.