PHP code example of ibpavlov / laravel-cors
1. Go to this page and download the library: Download ibpavlov/laravel-cors library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ibpavlov / laravel-cors example snippets
Barryvdh\Cors\ServiceProvider::class,
protected $middleware = [
// ...
\Barryvdh\Cors\HandleCors::class,
];
protected $middlewareGroups = [
'web' => [
// ...
],
'api' => [
// ...
\Barryvdh\Cors\HandleCors::class,
],
];
return [
/*
|--------------------------------------------------------------------------
| Laravel CORS
|--------------------------------------------------------------------------
|
| allowedOrigins, allowedHeaders and allowedMethods can be set to array('*')
| to accept any value.
|
*/
'supportsCredentials' => false,
'allowedOrigins' => ['*'],
'allowedHeaders' => ['Content-Type', 'X-Requested-With'],
'allowedMethods' => ['*'], // ex: ['GET', 'POST', 'PUT', 'DELETE']
'exposedHeaders' => [],
'maxAge' => 0,
]
$app->configure('cors');
$app->register(Barryvdh\Cors\ServiceProvider::class);
$app->middleware([
// ...
\Barryvdh\Cors\HandleCors::class,
]);
$app->routeMiddleware([
// ...
'cors' => \Barryvdh\Cors\HandleCors::class,
]);
protected $except = [
'api/*'
];