I am trying to call Laravel API in angular:
search(data){ console.log(data); this.http.get('http://localhost:8000/flight',JSON.stringify(data)) .subscribe(res=>{ console.log(res); }); } the above is working with GET request.
search(data){ console.log(data); this.http.post('http://localhost:8000/flight',JSON.stringify(data)) .subscribe(res=>{ console.log(res); }); } but not working with POST request
this is the error i get :
No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:4200' is therefore not allowed access.
even though i have my cors middelware written correctly
return $next($request)->header('Access-Control-Allow-Origin', '*') ->header('Access-Control-Allow-Credentials', true ) ->header('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS') ->header('Access-Control-Allow-Headers',' Origin, Content-Type, X-Auth-Token');