header('origin'); $header['Access-Control-Allow-Origin'] = $origin; if ($request->method(true) == 'OPTIONS') { $response = Response::create('ok')->code(200)->header($header); } else { $response = $next($request)->header($header); } return $response; } }