2019-11-12 22:32:28 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Middleware;
|
|
|
|
|
|
|
|
use Closure;
|
2019-11-13 12:39:53 +01:00
|
|
|
use Illuminate\Support\Facades\Response;
|
2019-11-12 22:32:28 +01:00
|
|
|
|
|
|
|
class Cors
|
|
|
|
{
|
2019-12-30 22:59:12 +01:00
|
|
|
public function handle($request, Closure $next)
|
|
|
|
{
|
2021-06-02 05:14:40 +02:00
|
|
|
if ($request->getMethod() == 'OPTIONS') {
|
|
|
|
header('Access-Control-Allow-Origin: *');
|
2019-11-12 22:50:12 +01:00
|
|
|
|
2021-06-02 05:14:40 +02:00
|
|
|
// ALLOW OPTIONS METHOD
|
|
|
|
$headers = [
|
|
|
|
'Access-Control-Allow-Methods'=> 'POST, GET, OPTIONS, PUT, DELETE',
|
2023-06-04 08:11:40 +02:00
|
|
|
'Access-Control-Allow-Headers'=> 'X-React,X-API-PASSWORD-BASE64,X-API-COMPANY-KEY,X-CLIENT-VERSION,X-API-SECRET,X-API-TOKEN,X-API-PASSWORD,DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Disposition,Range,X-CSRF-TOKEN,X-XSRF-TOKEN,X-LIVEWIRE',
|
2021-06-02 05:14:40 +02:00
|
|
|
];
|
2019-11-13 12:36:39 +01:00
|
|
|
|
2021-06-02 05:14:40 +02:00
|
|
|
return Response::make('OK', 200, $headers);
|
|
|
|
}
|
2019-11-13 12:36:39 +01:00
|
|
|
|
2019-12-30 22:59:12 +01:00
|
|
|
$response = $next($request);
|
2019-11-12 22:32:28 +01:00
|
|
|
|
2021-06-02 05:14:40 +02:00
|
|
|
$response->headers->set('Access-Control-Allow-Origin', '*');
|
|
|
|
$response->headers->set('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');
|
2023-06-04 08:11:40 +02:00
|
|
|
$response->headers->set('Access-Control-Allow-Headers', 'X-React,X-API-PASSWORD-BASE64,X-API-COMPANY-KEY,X-API-SECRET,X-API-TOKEN,X-API-PASSWORD,DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Disposition,Range,X-CSRF-TOKEN,X-XSRF-TOKEN,X-LIVEWIRE');
|
2023-01-22 23:49:40 +01:00
|
|
|
$response->headers->set('Access-Control-Expose-Headers', 'X-APP-VERSION,X-MINIMUM-CLIENT-VERSION,Content-Disposition');
|
2020-03-02 11:22:37 +01:00
|
|
|
$response->headers->set('X-APP-VERSION', config('ninja.app_version'));
|
2020-06-21 23:30:25 +02:00
|
|
|
$response->headers->set('X-MINIMUM-CLIENT-VERSION', config('ninja.minimum_client_version'));
|
2020-09-06 11:38:10 +02:00
|
|
|
|
2019-12-30 22:59:12 +01:00
|
|
|
return $response;
|
|
|
|
}
|
2022-06-21 11:57:17 +02:00
|
|
|
}
|