| Conditions | 3 |
| Paths | 3 |
| Total Lines | 19 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 25 | public function handle(Request $request, Closure $next) |
||
| 26 | { |
||
| 27 | header('Access-Control-Allow-Origin: *'); |
||
| 28 | |||
| 29 | $headers = [ |
||
| 30 | 'Access-Control-Allow-Methods' => 'POST, GET, OPTIONS, DELETE, PATCH', |
||
| 31 | 'Access-Control-Allow-Headers' => 'Content-Type, X-Auth-Token, Origin, Authorization', |
||
| 32 | ]; |
||
| 33 | |||
| 34 | if ($request->getMethod() == 'OPTIONS') { |
||
| 35 | return response('OK', Response::HTTP_OK, $headers); |
||
| 36 | } |
||
| 37 | |||
| 38 | $response = $next($request); |
||
| 39 | foreach ($headers as $key => $value) { |
||
| 40 | $response->headers->set($key, $value); |
||
| 41 | } |
||
| 42 | |||
| 43 | return $response; |
||
| 44 | } |
||
| 46 |