How to Allow All CORS Requests in Laravel 6

There are the Following The simple About laravel 6.2 access-control-allow-origin Full Information With Example and source code.

As I will cover this Post with live Working example to develop Easiest Way to Allow CORS in Laravel 6 or Any Version, so the cors header ‘access-control-allow-origin’ missing is used for this example is following below.

The Laravel Best “Access-Control-Allow-Origin in Laravel 6” Solution

app.php

Example 1: Easiest Way to Allow CORS in Laravel 6 or Any Version

header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: *');
header('Access-Control-Allow-Headers: *');

Second Solution

Example 2: cors header ‘access-control-allow-origin’ missing

Run this artisan command in CMD

php artisan make:middleware CorsSolution

App\Http\Middleware\CorsSolution.php

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, Authorizations');
}

App\Http\Kernel.php

protected $middleware = [
...
\App\Http\Middleware\CorsSolution::class,
];

I hope you get an idea about laravel 6.0 access-control-allow-origin.


#laravel 

 How to Allow All CORS Requests in Laravel 6
1.05 GEEK