jeudi 27 juin 2019

Laravel reponses giving incorrect code 200 instead of 401

I am having issues trying to get Laravel (5.8) to return a 401 HTTP status code.

Route (api.php)

route::get('test','testController@test');

Controller

public function test(){

   return response("error",401)->header('Content-Type','text/plain');

   // Also not working.
   // header("Content-Type: test/plain", 401);
   // print "error";
   // exit();
}

The result I am getting is a 200 instead the desired 401. I also test the plain PHP way with header() and terminate the execution with exit(), but no luck. Any help will be appreciated.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2X8rWDw
via IFTTT

Aucun commentaire:

Enregistrer un commentaire