Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 12 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
Cors | |
0.00% |
0 / 12 |
|
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 1 |
handle | |
0.00% |
0 / 12 |
|
0.00% |
0 / 1 |
6 |
1 | <?php |
2 | |
3 | namespace App\Http\Middleware; |
4 | |
5 | use Closure; |
6 | |
7 | class Cors |
8 | { |
9 | public function handle($request, Closure $next) |
10 | { |
11 | if ($request->isMethod('OPTIONS')) { |
12 | return response()->json([], 200, [ |
13 | 'Access-Control-Allow-Origin' => '*', |
14 | 'Access-Control-Allow-Methods' => 'POST, GET, OPTIONS, PUT, DELETE', |
15 | 'Access-Control-Allow-Headers' => 'Content-Type, X-Auth-Token, Origin, Authorization', |
16 | 'Access-Control-Allow-Credentials' => 'true', |
17 | ]); |
18 | } |
19 | |
20 | return $next($request) |
21 | ->header('Access-Control-Allow-Origin', '*') |
22 | ->header('Access-Control-Allow-Methods', 'POST, GET, OPTIONS, PUT, DELETE') |
23 | ->header('Access-Control-Allow-Headers', 'Content-Type, X-Auth-Token, Origin, Authorization') |
24 | ->header('Access-Control-Allow-Credentials', 'true'); |
25 | } |
26 | } |