public function handle($request, Closure $next) { $domains = ['http://localhost:8080']; if(isset($request->server()['HTTP_ORIGIN'])){ $origin = $request->server()['HTTP_ORIGIN']; if(in_array($origin, $domains)){ header('Access-Control-Allow-Origin: '. $origin); header('Access-Control-Allow-Headers: Origin, Content-type, Authorization'); } } return $next($request); }