| Conditions | 3 |
| Paths | 3 |
| Total Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 12 |
| Changes | 0 | ||
| 1 | <?php |
||
| 18 | public function handle($request, \Closure $next) |
||
| 19 | { |
||
| 20 | header('Access-Control-Allow-Origin: *'); |
||
| 21 | $headers = [ |
||
| 22 | 'Access-Control-Allow-Methods' => 'POST, GET, OPTIONS, PUT, DELETE', |
||
| 23 | 'Access-Control-Allow-Headers' => 'Content-Type, X-Auth-Token, Origin, Authorization' |
||
| 24 | ]; |
||
| 25 | if ($request->getMethod() === 'OPTIONS') { |
||
| 26 | return \Response::make('OK', 200, $headers); |
||
| 27 | } |
||
| 28 | $response = $next($request); |
||
| 29 | foreach ($headers as $key => $value) { |
||
| 30 | $response->headers->set($key, $value); |
||
| 31 | } |
||
| 32 | return $response; |
||
| 33 | } |
||
| 34 | } |
||
| 35 |